Documentation
¶
Overview ¶
Package queue provides different thread-safe generic queue implementations.
The blocking waits for the queue have elements available before retrieving from it. The blocking queue can be refilled in order to make all elements available again.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blocking ¶
type Blocking[T any] struct { // contains filtered or unexported fields }
Blocking provides a read-only queue for a list of T.
It supports operations for retrieving and adding elements to a FIFO queue. If there are no elements available the retrieve operations wait until elements are added to the queue.
func NewBlocking ¶
NewBlocking returns a new Blocking Queue containing the given elements..
func (*Blocking[T]) Refill ¶ added in v0.4.0
Refill attempts to refill the queue with the elements added at initialization. If there is no room for new elements in the channel the method blocks until there is an available spot for the element or the context is closed.
! There is a chance that this method can block indefinitely if other threads are constantly reading from the queue, so a timeout context would be recommended.