deadlock

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package deadlock is a set of simple utilities meant to detect deadlocks based on timeouts.

Index

Constants

View Source
const Timeout = 10 * time.Minute

Timeout is the default time after which a function is assumed to have deadlock.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

A Monitor is used to monitor a goroutine and ensure it completes various sections of code (called monitored code) within the specified timeout. To use this, create a new Monitor type for each goroutine, and modify the goroutine to record when it enters or exists monitored code.

func NewMonitor

func NewMonitor(timeout time.Duration, name string) *Monitor

NewMonitor returns a new monitor for the goroutine.

func (*Monitor) Enter

func (t *Monitor) Enter(desc string)

Enter records that the goroutine is entering a monitored section of code.

func (*Monitor) Exit

func (t *Monitor) Exit()

Exit records that the goroutine is exiting a monitored section of code.

func (*Monitor) IsRunning

func (t *Monitor) IsRunning() (bool, string)

IsRunning returns true if the goroutine is running a monitored code. It also returns a description of the monitored code being executed.

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

A Timer is used to time a function, and declare a deadlock if it does not return in the specified amount of time.

func NewTimer

func NewTimer(timeout time.Duration, desc string) *Timer

NewTimer returns a new timer that declares a deadlock if it is not stopped within the specified duration.

func (*Timer) Stop

func (t *Timer) Stop()

Stop stops a running timer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL