queue

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInit     = errors.New("queue is not init")
	ErrQueueFull   = errors.New("queue is full")
	ErrTakeTimeout = errors.New("take from queue timeout")
)

Functions

This section is empty.

Types

type BlockingQueue

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

func NewBlockingQueue

func NewBlockingQueue(cap int) *BlockingQueue

func (*BlockingQueue) Cap

func (bq *BlockingQueue) Cap() int

func (*BlockingQueue) Len

func (bq *BlockingQueue) Len() int

func (*BlockingQueue) Offer

func (bq *BlockingQueue) Offer(val interface{}) error

func (*BlockingQueue) Take

func (bq *BlockingQueue) Take(timeout time.Duration) (interface{}, error)

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

NewDelayQueue creates an instance of delayQueue with the specified size.

func (*DelayQueue) Cap

func (dq *DelayQueue) Cap() int

func (*DelayQueue) Len

func (dq *DelayQueue) Len() int

func (*DelayQueue) Offer

func (dq *DelayQueue) Offer(elem interface{}, expireAt time.Time) error

Offer inserts the element into the current queue.

func (*DelayQueue) Take

func (dq *DelayQueue) Take(timeout time.Duration) interface{}

Take inserts the element into the current queue.

type Item

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

Item is a priority queue as implemented by a min heap ie. the 0th element is the *lowest* value

func (*Item) Less

func (i *Item) Less(other interface{}) bool

func (*Item) String

func (i *Item) String() string

type PriorityQueue

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

PriorityQueue priority queue struct

func NewPriorityQueue

func NewPriorityQueue(size int) *PriorityQueue

func (*PriorityQueue) Cap

func (pq *PriorityQueue) Cap() int

func (*PriorityQueue) Fix

func (pq *PriorityQueue) Fix(elem *Item, i int)

func (*PriorityQueue) Full

func (pq *PriorityQueue) Full() bool

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

func (*PriorityQueue) PeekAndShift

func (pq *PriorityQueue) PeekAndShift(max int64) (*Item, int64)

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() *Item

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(elem *Item) error

func (*PriorityQueue) Remove

func (pq *PriorityQueue) Remove(i int) *Item

func (*PriorityQueue) Top

func (pq *PriorityQueue) Top() *Item

type Queue

type Queue interface {
	Take(timeout time.Duration) (interface{}, error)
	Offer(val interface{}) error
	Len() int
	Cap() int
}

type UnboundQueue

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

func NewUnboundQueue

func NewUnboundQueue() *UnboundQueue

func (*UnboundQueue) Cap

func (uq *UnboundQueue) Cap() int

func (*UnboundQueue) Len

func (uq *UnboundQueue) Len() int

func (*UnboundQueue) Offer

func (uq *UnboundQueue) Offer(val interface{}) error

func (*UnboundQueue) Take

func (uq *UnboundQueue) Take(timeout time.Duration) (interface{}, error)

Jump to

Keyboard shortcuts

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