queue

package
v0.0.0-...-f97f0ba Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout = errors.New("queue timeout")
	ErrFull    = errors.New("queue full")
	ErrEmpty   = errors.New("queue empty")
)

Functions

This section is empty.

Types

type ChannelQueue

type ChannelQueue chan interface{}

func NewChannelQueue

func NewChannelQueue(capacity int) ChannelQueue

func (ChannelQueue) Empty

func (cq ChannelQueue) Empty() bool

func (ChannelQueue) Len

func (cq ChannelQueue) Len() int

func (ChannelQueue) Pop

func (cq ChannelQueue) Pop(timeout ...time.Duration) (interface{}, error)

func (ChannelQueue) Push

func (cq ChannelQueue) Push(item interface{}, timeout ...time.Duration) error

type PriorityQueue

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

func NewPriorityQueue

func NewPriorityQueue(comparePriority func(a, b interface{}) bool, sizeHint ...int) *PriorityQueue

Function comparePriority reports whether the element a has higher priority than the element b.

func (*PriorityQueue) Empty

func (pq *PriorityQueue) Empty() bool

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(item interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type Queue

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

func NewQueue

func NewQueue() *Queue

func (*Queue) Empty

func (q *Queue) Empty() bool

func (*Queue) Len

func (q *Queue) Len() int

func (*Queue) Pop

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

func (*Queue) Push

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

type RingQueue

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

RingQueue is a bounded MPMC ring buffer queue that achieves concurrency with CAS operations only.

func NewRingQueue

func NewRingQueue(capacity int, spin bool) *RingQueue

NewRingQueue will allocate a RingQueue with the specified capacity. The `spin` specifies the waiting strategy when operation will be blocked: if true, spin on CAS; otherwise, wait on channel for notification.

func (*RingQueue) Empty

func (rq *RingQueue) Empty() bool

Empty returns whether the queue is empty.

func (*RingQueue) Len

func (rq *RingQueue) Len() int

Len returns the number of items in the queue.

func (*RingQueue) Pop

func (rq *RingQueue) Pop(timeout ...time.Duration) (interface{}, error)

Push will return the next item in the queue. If the queue is empty, block until an item can be returned. If a nonzero timeout is specified, block no more than the timeout duration and return ErrTimeout. If timeout is zero, immediately return ErrEmpty.

func (*RingQueue) Push

func (rq *RingQueue) Push(item interface{}, timeout ...time.Duration) error

Push adds the item to the queue. If the queue is full, will block until an item is added to the queue. If a nonzero timeout is specified, block no more than the timeout duration and return ErrTimeout. If timeout is zero, immediately return ErrFull.

Jump to

Keyboard shortcuts

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