Documentation
¶
Overview ¶
This example demonstrates a priority queue built using the heap interface.
Index ¶
- func Remove(task *Item)
- func Set(timer *SuperTimer)
- func Size() int
- func Stop()
- func Wait()
- type AtomicBool
- type Delayed
- type Item
- type PriorityQueue
- func (pq *PriorityQueue) Clear()
- func (pq *PriorityQueue) Len() int
- func (pq *PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Peek() interface{}
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(x interface{})
- func (pq *PriorityQueue) Remove(item *Item)
- func (pq *PriorityQueue) Swap(i, j int)
- func (pq *PriorityQueue) Update(item *Item, value string, priority int64)
- type SuperTimer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Set ¶
func Set(timer *SuperTimer)
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
atomicBool is a wrapper around uint32 for usage as a boolean value with atomic access.
func NewAtomicBool ¶
func NewAtomicBool(flag bool) *AtomicBool
func (*AtomicBool) IsSet ¶
func (ab *AtomicBool) IsSet() bool
IsSet returns whether the current boolean value is true
func (*AtomicBool) IsTrue ¶
func (ab *AtomicBool) IsTrue() bool
func (*AtomicBool) Set ¶
func (ab *AtomicBool) Set(value bool)
Set sets the value of the bool regardless of the previous value
type Item ¶
type Item struct {
// when task is ready, execute OnTrigger function
OnTrigger func(scheduledExecTime time.Time, param interface{})
// contains filtered or unexported fields
}
nolint: govet An Item is something we manage in a priority queue.
func AddComplex ¶
type PriorityQueue ¶
type PriorityQueue []*Item
A PriorityQueue implements heap.Interface and holds Items.
func (*PriorityQueue) Clear ¶
func (pq *PriorityQueue) Clear()
func (*PriorityQueue) Len ¶
func (pq *PriorityQueue) Len() int
func (*PriorityQueue) Less ¶
func (pq *PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Peek ¶
func (pq *PriorityQueue) Peek() interface{}
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (*PriorityQueue) Remove ¶
func (pq *PriorityQueue) Remove(item *Item)
func (*PriorityQueue) Swap ¶
func (pq *PriorityQueue) Swap(i, j int)
type SuperTimer ¶
type SuperTimer struct {
Wgp *sync.WaitGroup
UniTimer *time.Timer
WorkerCount int
ExitChan chan int
PQ PriorityQueue
RunningFlag *AtomicBool
// contains filtered or unexported fields
}
nolint: govet
func NewSuperTimer ¶
func NewSuperTimer(workCount int) *SuperTimer
func (*SuperTimer) Add ¶
func (st *SuperTimer) Add(pItem *Item)
func (*SuperTimer) Consume ¶
func (timer *SuperTimer) Consume()
func (*SuperTimer) Remove ¶
func (st *SuperTimer) Remove(pItem *Item)
func (*SuperTimer) Size ¶
func (st *SuperTimer) Size() int
func (*SuperTimer) Stop ¶
func (st *SuperTimer) Stop()
func (*SuperTimer) Take ¶
func (st *SuperTimer) Take() *Item
func (*SuperTimer) Wait ¶
func (st *SuperTimer) Wait()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.