Documentation
¶
Overview ¶
Package coalesce provides an in-order queue for collecting outputs from a producer to provide inputs to a consumer. Coalescing happens when an output has been produced more than once by the producer before being consumed. In this case the outputs are coalesced and delivered only once.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsClosedQueue ¶
IsClosedQueue returns whether a given error is coalesce.errClosedQueue.
Types ¶
type Queue ¶
Queue is a structure that implements in-order delivery of coalesced inputs. Operations on Queue are threadsafe and any number of producers may contribute to the queue and any number of consumers may receive, however, no fairness among consumers is guaranteed and it is possible for starvation to occur.
func (*Queue) Insert ¶
Insert adds i to the queue and returns true if i does not already exist. Insert returns an error if the Queue has been closed.
func (*Queue) Len ¶
Len returns the current length of the queue, useful for reporting statistics. Since the queue is designed to be operated on by one or more producers and one or more consumers, this return value only indicates what the length was at the instant it was evaluated which may change before the caller gets the return value.