queue

package
v0.0.0-...-24e5678 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpireQueue

type ExpireQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ExpireQueue provides sequential expirations by groups

func NewExpireQueue

func NewExpireQueue() *ExpireQueue

NewExpireQueue returns ExpireQueue

func (*ExpireQueue) AddGroup

func (q *ExpireQueue) AddGroup(interval time.Duration)

AddGroup adds and runs a expire gruop

func (*ExpireQueue) AddGroupRepeat

func (q *ExpireQueue) AddGroupRepeat(n int, in time.Duration)

AddGroupRepeat adds and runs a expire gruop n times

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

func (*ExpireQueue) Size

func (q *ExpireQueue) Size() int

Size returns a queue size

type IDoubleKeyQueue

type IDoubleKeyQueue interface {
	Push(v IDoubleKeyQueueItem)
	Pop() IDoubleKeyQueueItem
	Peek() IDoubleKeyQueueItem
	DPeek() IKeyPriorityQueue
	Get(key interface{}) IDoubleKeyQueueItem
	DGet(key interface{}) IKeyPriorityQueue
	RemoveKey(key interface{})
	List() []IDoubleKeyQueueItem
	Iter(f func(IDoubleKeyQueueItem) bool)
	Size() int
	Clear()
}

func NewDoubleKeyPriorityQueue

func NewDoubleKeyPriorityQueue(pt PriorityType) IDoubleKeyQueue

type IDoubleKeyQueueItem

type IDoubleKeyQueueItem interface {
	IKeyQueueItem
	DKey() interface{}
	DPriority() uint64
}

type IKeyPriorityQueue

type IKeyPriorityQueue interface {
	Push(v IKeyQueueItem)
	Pop() IKeyQueueItem
	Peek() IKeyQueueItem
	Get(key interface{}) IKeyQueueItem
	RemoveKey(key interface{})
	Iter(f func(IKeyQueueItem) bool)
	Size() int
	Clear()
}

func NewKeyPriorityQueue

func NewKeyPriorityQueue(highest PriorityType) IKeyPriorityQueue

type IKeyQueueItem

type IKeyQueueItem interface {
	Key() interface{}
	// contains filtered or unexported methods
}

func NewKeyPriorityQueueItem

func NewKeyPriorityQueueItem(i IKeyQueueItem) IKeyQueueItem

type IPriorityQueue

type IPriorityQueue interface {
	Push(v IPriorityQueueItem)
	Pop() IPriorityQueueItem
	Peek() IPriorityQueueItem
	Iter(f func(IPriorityQueueItem) bool)
	Remove(index int)
	Size() int
	Clear()
}

func NewPriorityQueue

func NewPriorityQueue(pt PriorityType) IPriorityQueue

type IPriorityQueueItem

type IPriorityQueueItem interface {
	Index() int
	// contains filtered or unexported methods
}

func NewPriorityQueueItem

func NewPriorityQueueItem(v iPriorityQueueItem) IPriorityQueueItem

type ItemExpireHandler

type ItemExpireHandler interface {
	// OnItemExpired is called when the item is expired
	OnItemExpired(interval time.Duration, key string, item interface{}, IsLast bool) TxExpiredType
}

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 NewLinkedQueue

func NewLinkedQueue() *LinkedQueue

NewLinkedQueue make a LinkedQueue

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

func (*LinkedQueue) Size

func (q *LinkedQueue) Size() int

Size returns the number of items

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

A PriorityQueue implements heap.Interface and holds Items.

func (*PriorityQueue) Clear

func (q *PriorityQueue) Clear()

clear is remove all

func (*PriorityQueue) Iter

func (q *PriorityQueue) Iter(f func(IPriorityQueueItem) bool)

Iter iterates queue items

func (*PriorityQueue) Peek

func (*PriorityQueue) Pop

func (*PriorityQueue) Push

func (q *PriorityQueue) Push(v IPriorityQueueItem)

func (*PriorityQueue) Remove

func (q *PriorityQueue) Remove(i int)

Iter iterates queue items

func (*PriorityQueue) Size

func (q *PriorityQueue) Size() int

Size return of queue size

type PriorityType

type PriorityType int
const (
	HIGHEST PriorityType = iota
	LOWEST
)

type Queue

type Queue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Queue provides a basic queue ability with the peek method

func NewQueue

func NewQueue() *Queue

NewQueue returns a Queue

func (*Queue) Iter

func (q *Queue) Iter(fn func(v interface{}))

Iter iterates queue items

func (*Queue) Peek

func (q *Queue) Peek() interface{}

Peek fetch the top item without removing it

func (*Queue) Pop

func (q *Queue) Pop() interface{}

Pop returns a item at the top of the queue

func (*Queue) Push

func (q *Queue) Push(item interface{})

Push inserts a item at the bottom of the queue

func (*Queue) Size

func (q *Queue) Size() int

Size returns the number of items

type SortedQueue

type SortedQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SortedQueue sorts items by the priority

func NewSortedQueue

func NewSortedQueue() *SortedQueue

NewSortedQueue returns a SortedQueue

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

func (*SortedQueue) Size

func (q *SortedQueue) Size() int

Size returns the number of items

type TxExpiredType

type TxExpiredType int
const (
	Resend TxExpiredType = iota
	Expired
	Remain
	Error
)

func (TxExpiredType) String

func (m TxExpiredType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL