Documentation
¶
Overview ¶
Package timerqueue provides a timer queue for a list of items that should be processed after a fixed duration of time from when they are added to the queue. All operations are safe for concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue holds a list of elements. When a new element is added to the queue, the queue callback will be called with the element after the set queue duration.
func (*Queue) Add ¶
func (q *Queue) Add(v interface{})
Add adds a new element to the timer Queue, starting a timer for the fixed duration for the queue. Once the duration has passed, the queue callback will be called.
func (*Queue) Clear ¶
func (q *Queue) Clear() []interface{}
Clear removes all elements from the queue. Returns a slice of the elements cleared from the queue.
func (*Queue) Flush ¶
func (q *Queue) Flush()
Flush calls the callback for each element in the queue. Any new element added while flushing, will not be called.