Documentation ¶
Index ¶
- Variables
- func ExecuteInParallel(q *Queue, fn func(interface{}))
- type CircularUnboundedQueue
- func (q *CircularUnboundedQueue) Cap() int
- func (q *CircularUnboundedQueue) InitialCap() int
- func (q *CircularUnboundedQueue) IsEmpty() bool
- func (q *CircularUnboundedQueue) Len() int
- func (q *CircularUnboundedQueue) Peek() interface{}
- func (q *CircularUnboundedQueue) Pop() interface{}
- func (q *CircularUnboundedQueue) Push(t interface{}) bool
- func (q *CircularUnboundedQueue) Reset()
- type Queue
- func (q *Queue) Dispose() []interface{}
- func (q *Queue) Disposed() bool
- func (q *Queue) Empty() bool
- func (q *Queue) Get(number int64) ([]interface{}, error)
- func (q *Queue) GetUntil(checker func(item interface{}) bool) ([]interface{}, error)
- func (q *Queue) Len() int64
- func (q *Queue) Peek() (interface{}, error)
- func (q *Queue) Poll(number int64, timeout time.Duration) ([]interface{}, error)
- func (q *Queue) Put(items ...interface{}) error
- type SPMCLockFreeQ
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDisposed is returned when an operation is performed on a disposed // queue. ErrDisposed = errors.New(`queue: disposed`) // ErrTimeout is returned when an applicable queue operation times out. ErrTimeout = errors.New(`queue: poll timed out`) // ErrEmptyQueue is returned when an non-applicable queue operation was called // due to the queue's empty item state ErrEmptyQueue = errors.New(`queue: empty queue`) )
Functions ¶
func ExecuteInParallel ¶
func ExecuteInParallel(q *Queue, fn func(interface{}))
ExecuteInParallel will (in parallel) call the provided function with each item in the queue until the queue is exhausted. When the queue is exhausted execution is complete and all goroutines will be killed. This means that the queue will be disposed so cannot be used again.
Types ¶
type CircularUnboundedQueue ¶ added in v1.11.14
type CircularUnboundedQueue struct {
// contains filtered or unexported fields
}
CircularUnboundedQueue is a circular structure and will grow automatically if it exceeds the capacity. CircularUnboundedQueue is not thread-safe.
func NewCircularUnboundedQueue ¶ added in v1.11.14
func NewCircularUnboundedQueue(capacity int) *CircularUnboundedQueue
func NewCircularUnboundedQueueWithQuota ¶ added in v1.11.16
func NewCircularUnboundedQueueWithQuota(capacity, quota int) *CircularUnboundedQueue
func (*CircularUnboundedQueue) Cap ¶ added in v1.11.14
func (q *CircularUnboundedQueue) Cap() int
func (*CircularUnboundedQueue) InitialCap ¶ added in v1.11.16
func (q *CircularUnboundedQueue) InitialCap() int
func (*CircularUnboundedQueue) IsEmpty ¶ added in v1.11.14
func (q *CircularUnboundedQueue) IsEmpty() bool
func (*CircularUnboundedQueue) Len ¶ added in v1.11.14
func (q *CircularUnboundedQueue) Len() int
func (*CircularUnboundedQueue) Peek ¶ added in v1.11.14
func (q *CircularUnboundedQueue) Peek() interface{}
func (*CircularUnboundedQueue) Pop ¶ added in v1.11.14
func (q *CircularUnboundedQueue) Pop() interface{}
func (*CircularUnboundedQueue) Push ¶ added in v1.11.14
func (q *CircularUnboundedQueue) Push(t interface{}) bool
func (*CircularUnboundedQueue) Reset ¶ added in v1.11.14
func (q *CircularUnboundedQueue) Reset()
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the struct responsible for tracking the state of the queue.
func (*Queue) Dispose ¶
func (q *Queue) Dispose() []interface{}
Dispose will dispose of this queue and returns the items disposed. Any subsequent calls to Get or Put will return an error.
func (*Queue) Disposed ¶
Disposed returns a bool indicating if this queue has had disposed called on it.
func (*Queue) Get ¶
Get retrieves items from the queue. If there are some items in the queue, get will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue.
func (*Queue) GetUntil ¶
GetUntil gets a function and returns a list of items that match the checker until the checker returns false. This does not wait if there are no items in the queue.
func (*Queue) Peek ¶
Peek returns a the first item in the queue by value without modifying the queue.
func (*Queue) Poll ¶
Poll retrieves items from the queue. If there are some items in the queue, Poll will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue or the provided timeout is reached. A non-positive timeout will block until items are added. If a timeout occurs, ErrTimeout is returned.
type SPMCLockFreeQ ¶ added in v1.9.5
type SPMCLockFreeQ interface { PushHead(val interface{}) bool PopHead() (interface{}, bool) PopTail() (interface{}, bool) }
SPMCLockFreeQ is a lock-free queue.
func NewSPMCLockFreeQ ¶ added in v1.9.5
func NewSPMCLockFreeQ(n int) (SPMCLockFreeQ, error)
NewSPMCLockFreeQ new a SPMCLockFreeQ instance.