Documentation
¶
Overview ¶
Package queue adapts ChannX to typed event streams, with atomic admission and explicit drain/abort lifecycle. Each Queue owns one ChannX instance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Item ¶
Item supplies a value and its caller-estimated retained size. Bytes does not impose a memory limit or account for the queue's own allocations.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue is a dynamically growing event FIFO whose zero value is ready for use. It must not be copied after first use. Growth is limited by available memory; delivery is not persistent. Admission is serialized, and Pop calls share one cancellable consumer token. Only the owner goroutine writes to or closes the underlying ChannX. Callers must Close and drain, or Abort, when finished.
func (*Queue[T]) Abort ¶
Abort wakes waiting Pops, closes admission through the owner, and discards pending envelopes until ChannX terminates. It is O(backlog), independent of an external consumer, and preserves an earlier Close's cause.
func (*Queue[T]) Close ¶
Close rejects further admission and requests the owner to close ChannX after all acknowledged pushes. It does not wait for consumer drain. The first cause is preserved; a nil cause becomes io.EOF. Drain or Abort to release resources.
func (*Queue[T]) Pop ¶
Pop waits for a value or terminal cause. Cancellation cancels only this wait; even an envelope fetched concurrently with cancellation remains available to the next Pop. Nil contexts are invalid.