Documentation ¶
Index ¶
- type ExpireQueue
- type ItemExpireHandler
- type LinkedQueue
- func (q *LinkedQueue) Has(Key hash.Hash256) bool
- func (q *LinkedQueue) Iter(fn func(keyMap hash.Hash256, v interface{}))
- func (q *LinkedQueue) Pop() interface{}
- func (q *LinkedQueue) Push(Key hash.Hash256, item interface{}) bool
- func (q *LinkedQueue) Remove(Key hash.Hash256) interface{}
- func (q *LinkedQueue) Size() int
- type Queue
- type SortedQueue
- func (q *SortedQueue) Find(Priority uint64) interface{}
- func (q *SortedQueue) FindOrInsert(value interface{}, Priority uint64) interface{}
- func (q *SortedQueue) Insert(value interface{}, Priority uint64)
- func (q *SortedQueue) Iter(fn func(v interface{}, priority uint64))
- func (q *SortedQueue) Peek() (interface{}, uint64)
- func (q *SortedQueue) Pop() interface{}
- func (q *SortedQueue) PopUntil(Priority uint64) interface{}
- func (q *SortedQueue) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpireQueue ¶
ExpireQueue provides sequential expirations by groups
func (*ExpireQueue) AddGroup ¶
func (q *ExpireQueue) AddGroup(interval time.Duration)
AddGroup adds and runs a expire gruop
func (*ExpireQueue) AddHandler ¶
func (q *ExpireQueue) AddHandler(handler ItemExpireHandler)
AddHandler adds a item expire handler
func (*ExpireQueue) Push ¶
func (q *ExpireQueue) Push(key string, item interface{})
Push adds a item to the expiration flow
func (*ExpireQueue) Remove ¶
func (q *ExpireQueue) Remove(key string)
Remove removes a item from the expiration flow
type ItemExpireHandler ¶
type ItemExpireHandler interface { // OnItemExpired is called when the item is expired OnItemExpired(interval time.Duration, key string, item interface{}, IsLast bool) }
ItemExpireHandler handles a group expire event
type LinkedQueue ¶
type LinkedQueue struct { sync.Mutex Head *linkedItem Tail *linkedItem // contains filtered or unexported fields }
LinkedQueue is designed to allow users to remove the item by the key
func (*LinkedQueue) Has ¶
func (q *LinkedQueue) Has(Key hash.Hash256) bool
Has returns the key is exist of not
func (*LinkedQueue) Iter ¶
func (q *LinkedQueue) Iter(fn func(keyMap hash.Hash256, v interface{}))
Iter iterates queue items
func (*LinkedQueue) Pop ¶
func (q *LinkedQueue) Pop() interface{}
Pop returns a item at the top of the queue
func (*LinkedQueue) Push ¶
func (q *LinkedQueue) Push(Key hash.Hash256, item interface{}) bool
Push inserts the item with the key at the bottom of the queue
func (*LinkedQueue) Remove ¶
func (q *LinkedQueue) Remove(Key hash.Hash256) interface{}
Remove deletes a item by the key
type Queue ¶
Queue provides a basic queue ability with the peek method
type SortedQueue ¶
SortedQueue sorts items by the priority
func (*SortedQueue) Find ¶
func (q *SortedQueue) Find(Priority uint64) interface{}
Find fetch the target priority item without removing it
func (*SortedQueue) FindOrInsert ¶
func (q *SortedQueue) FindOrInsert(value interface{}, Priority uint64) interface{}
FindOrInsert finds the item of the priority if it exists or inserts the item by the priority
func (*SortedQueue) Insert ¶
func (q *SortedQueue) Insert(value interface{}, Priority uint64)
Insert inserts the item by the priority
func (*SortedQueue) Iter ¶
func (q *SortedQueue) Iter(fn func(v interface{}, priority uint64))
Iter iterates queue items
func (*SortedQueue) Peek ¶
func (q *SortedQueue) Peek() (interface{}, uint64)
Peek fetch the top item without removing it
func (*SortedQueue) Pop ¶
func (q *SortedQueue) Pop() interface{}
Pop returns a item at the top of the queue
func (*SortedQueue) PopUntil ¶
func (q *SortedQueue) PopUntil(Priority uint64) interface{}
PopUntil returns a item at the top of the queue