Documentation ¶
Overview ¶
Package queue provides a queue to processes elements in FIFO order using a specified handler, while allowing non-blocking writes to the queue. The queue may be bounded in size or unbounded.
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
}
A Queue is a set of elements that are processed in FIFO order. The writes to the queue are non-blocking and the client can read from a channel it can access by Receive(). The size of the queue is either bounded or unbounded. Note that counters such as max/count used for synchronization are managed under the queue lock, while counters for book keeping are handled via the atomic package.
func NewBounded ¶
NewBounded creates a new bounded queue.
func NewUnbounded ¶
NewUnbounded creates a new unbounded queue.
func (*Queue) DequeueCount ¶
DequeueCount returns the number of elements dequeued from the queue.
func (*Queue) EnqueueCount ¶
EnqueueCount returns the number of elements enqueued in the queue.
func (*Queue) Receive ¶
func (q *Queue) Receive() chan interface{}
Receive returns the channel that the queue will output its elements to the client.