Documentation ¶
Index ¶
- func DumpHeap() (string, int)
- func DumpPProfStack() (string, int)
- func DumpRuntimeStack() string
- type PriorityQueue
- func (pq *PriorityQueue) Add(key string, priority int, value interface{}) error
- func (pq *PriorityQueue) CheckValidity() []string
- func (pq *PriorityQueue) DebugString() string
- func (pq *PriorityQueue) Dump() []map[string]interface{}
- func (pq *PriorityQueue) HasKey(key string) bool
- func (pq *PriorityQueue) IsEmpty() bool
- func (pq *PriorityQueue) Peek() interface{}
- func (pq *PriorityQueue) Pop() (interface{}, error)
- func (pq *PriorityQueue) Remove(key string) (interface{}, error)
- func (pq *PriorityQueue) Set(key string, priority int) error
- func (pq *PriorityQueue) Size() int
- func (pq *PriorityQueue) Values() []interface{}
- type Timer
- type TimerState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpPProfStack ¶
DumpPProfStack uses pprof to inspect goroutines
func DumpRuntimeStack ¶
func DumpRuntimeStack() string
DumpRuntimeStack uses runtime to inspect goroutines
Types ¶
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue uses a max heap, and provides efficient changing of priority.
func (*PriorityQueue) Add ¶
func (pq *PriorityQueue) Add(key string, priority int, value interface{}) error
Add adds an element. 'key' must be unique.
func (*PriorityQueue) CheckValidity ¶
func (pq *PriorityQueue) CheckValidity() []string
CheckValidity should always return an empty slice -- it is just a debugging tool. If it returns a non-empty slice, then there's a bug somewhere in the heap code.
func (*PriorityQueue) DebugString ¶
func (pq *PriorityQueue) DebugString() string
DebugString should only be used for debugging.
func (*PriorityQueue) Dump ¶
func (pq *PriorityQueue) Dump() []map[string]interface{}
Dump should only be used for debugging.
func (*PriorityQueue) HasKey ¶
func (pq *PriorityQueue) HasKey(key string) bool
HasKey returns whether the priority queue has the key.
func (*PriorityQueue) Peek ¶
func (pq *PriorityQueue) Peek() interface{}
Peek returns the highest priority item, or nil if empty.
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() (interface{}, error)
Pop removes the highest priority element, returning an error if empty.
func (*PriorityQueue) Remove ¶
func (pq *PriorityQueue) Remove(key string) (interface{}, error)
Remove removes the value associated with the key from the priority queue, returning an error if it can't be found.
func (*PriorityQueue) Set ¶
func (pq *PriorityQueue) Set(key string, priority int) error
Set changes the priority of 'value' if it can be found, and returns an error if not.
func (*PriorityQueue) Size ¶
func (pq *PriorityQueue) Size() int
Size returns the number of elements in the queue.
func (*PriorityQueue) Values ¶
func (pq *PriorityQueue) Values() []interface{}
Values should only be used for debugging.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer periodically executes `action`, waiting `delay` between invocation starts. If `action` takes longer than `delay`, invocations will be dropped. It stops when receiving an event on `stop`. It's basically a time.Ticker with additional functionality for pausing and resuming.
func NewRunningTimer ¶
func NewRunningTimer(name string, delay time.Duration, stop <-chan struct{}, runImmediately bool, action func()) *Timer
NewRunningTimer creates a new timer which is running
func (*Timer) Pause ¶
Pause temporarily stops the timer. It returns an error if the timer could not be paused.
type TimerState ¶
type TimerState int
TimerState describes the state of a timer
const ( TimerStateReady TimerState = iota TimerStateRunningAction TimerState = iota TimerStatePaused TimerState = iota TimerStateStopped TimerState = iota )
.....