import "v.io/x/ref/runtime/internal/lib/upcqueue"
Package upcqueue implements an unbounded producer/consumer queue. An unbounded producer/consumer queue is a concurrent buffer supporting multiple concurrent producers and consumers, with timeouts. The queue can be closed from either end, by the producer and/or the consumer. When closed, the contents are discarded, and subsequent operations return an error.
Note: the main reason to use a producer/consumer queue instead of a channel is to allow the consumer to close the channel. This queue can be used for many-to-many communication with multiple producers and/or multiple consumers. Any of the producers and any of the consumers are allowed to close the queue.
type T struct {
// contains filtered or unexported fields
}
T is an unbounded producer/consumer queue. It fulfills the same purpose as a Go channel, the main advantage is that the Put() operation does not panic, even after the queue is closed. The main disadvantage is that the T can't be used in a select operation.
New returns a producer/consumer queue.
Close closes the queue, without discarding the contents. All Put* operations currently running may, or may not, add their values to the queue. All Put* operations that happen-after the Close will fail.
Get returns the next item from the queue, or an error if the queue is closed or the operation is cancelled.
IsClosed returns whether the queue has been closed (with Close or Shutdown).
Put adds an item to the queue, or returns an error if the queue is closed.
Shutdown closes the queue and returns the contents. Any concurrent Get and Put operations might exchange values, but all operations that happen-after the Shutdown will fail.
TryGet returns the next item from the queue if there is one.
Package upcqueue imports 4 packages (graph) and is imported by 5 packages. Updated 2020-09-08. Refresh now. Tools for package owners.