Documentation ¶
Overview ¶
from: https://github.com/RussellLuo/timingwheel/blob/master/delayqueue/delayqueue.go
Index ¶
- type DelayQueue
- type Item
- type PriorityQueue
- func (pq PriorityQueue) Len() int
- func (pq PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) PeekAndShift(max int64) (*Item, int64)
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Push(x interface{})
- func (pq PriorityQueue) Swap(i, j int)
- func (pq *PriorityQueue) Top() (top *Item)
- func (pq *PriorityQueue) Update(item *Item, value interface{}, priority int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelayQueue ¶
type DelayQueue struct { C chan interface{} // contains filtered or unexported fields }
DelayQueue is an unbounded blocking queue of *Delayed* elements, in which an element can only be taken when its delay has expired. The head of the queue is the *Delayed* element whose delay expired furthest in the past.
func NewDelayQueue ¶
func NewDelayQueue(size int) *DelayQueue
New creates an instance of delayQueue with the specified size.
func (*DelayQueue) Do ¶
func (dq *DelayQueue) Do(exitC chan struct{}, do func(interface{}))
from delay queue ch get elem to do
func (*DelayQueue) Offer ¶
func (dq *DelayQueue) Offer(elem interface{}, expiration int64)
Offer inserts the element into the current queue.
func (*DelayQueue) Poll ¶
func (dq *DelayQueue) Poll(exitC chan struct{}, nowF func() int64)
Poll starts an infinite loop, in which it continually waits for an element to expire and then send the expired element to the channel C.
type PriorityQueue ¶
type PriorityQueue []*Item
this is a priority queue as implemented by a min heap ie. the 0th element is the *lowest* value
func NewPriorityQueue ¶
func NewPriorityQueue(capacity int) PriorityQueue
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (*PriorityQueue) PeekAndShift ¶
func (pq *PriorityQueue) PeekAndShift(max int64) (*Item, int64)
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
func (*PriorityQueue) Top ¶
func (pq *PriorityQueue) Top() (top *Item)
func (*PriorityQueue) Update ¶
func (pq *PriorityQueue) Update(item *Item, value interface{}, priority int64)
update item priority