sendqueue

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sendqueue orders cold-path admission with FIFO permits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Permit

type Permit struct {
	// contains filtered or unexported fields
}

Permit is one reservation in a Queue. Its links and membership are guarded by the queue's mutex; queue and ready are immutable after construction.

func (*Permit) Ready

func (p *Permit) Ready() <-chan struct{}

Ready closes once the permit becomes head. Releasing a permit before it is granted leaves Ready open. A nil or zero-value permit has a nil Ready channel.

func (*Permit) Release

func (p *Permit) Release()

Release removes this reservation, granting the next head if needed. It is safe concurrently, is idempotent, and does nothing for nil or zero permits.

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue grants its head permit and parks later reservations. Its zero value is ready to use. A Queue must not be copied after first use.

func (*Queue) Drained

func (q *Queue) Drained() <-chan struct{}

Drained returns one stable completion channel, also before Seal. It closes only once the generation is sealed and empty; callers never allocate a per-waiter signal.

func (*Queue) Pending

func (q *Queue) Pending() bool

Pending reports whether the queue has any unreleased reservations.

func (*Queue) Reserve

func (q *Queue) Reserve() (*Permit, bool)

Reserve appends a permit and reports whether it started an empty queue. It panics if the queue was sealed; callers holding a stale queue use TryReserve.

func (*Queue) Seal

func (q *Queue) Seal() <-chan struct{}

Seal fixes the generation's membership. The shared channel closes after its last existing permit releases, immediately if the generation is already empty.

func (*Queue) TryReserve

func (q *Queue) TryReserve() (*Permit, bool, bool)

TryReserve appends a permit unless the queue is sealed. Only the head is ready; its successor becomes ready when the head releases. A refusal allocates nothing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL