Documentation
¶
Overview ¶
Package packetqueue implements bounded priority queues for packet ownership.
Index ¶
- Variables
- type Item
- type Limits
- type Priority
- type Queue
- func (q *Queue[T]) Bytes() int
- func (q *Queue[T]) Close()
- func (q *Queue[T]) Len() int
- func (q *Queue[T]) Pop(ctx context.Context) (Item[T], error)
- func (q *Queue[T]) Push(item Item[T]) error
- func (q *Queue[T]) Ready() <-chan struct{}
- func (q *Queue[T]) TryPop() (Item[T], error)
- func (q *Queue[T]) TryPopPriority(priority Priority) (Item[T], error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidLimits indicates non-positive packet or byte limits. ErrInvalidLimits = errors.New("invalid queue limits") // ErrInvalidItem indicates a non-positive item size or missing deadline. ErrInvalidItem = errors.New("invalid queue item") // ErrFull indicates that accepting an item would exceed a queue limit. ErrFull = errors.New("queue full") // ErrExpired indicates an item already beyond its deadline. ErrExpired = errors.New("item expired") // ErrClosed indicates an operation on a closed queue. ErrClosed = errors.New("queue closed") // ErrEmpty indicates that a nonblocking dequeue found no unexpired item. ErrEmpty = errors.New("queue empty") )
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item[T any] struct { Value T Size int Priority Priority Deadline time.Time // contains filtered or unexported fields }
Item owns one queued value and its scheduling metadata.
func (*Item[T]) ReleaseRetention ¶
func (i *Item[T]) ReleaseRetention()
ReleaseRetention releases aggregate capacity retained by an item outside a queue.
func (*Item[T]) RestoreRetention ¶
RestoreRetention returns a failed transfer to the item and restores its queue byte charge.
type Priority ¶
type Priority uint8
Priority controls dequeue order without changing packet deadlines.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue is a concurrent bounded priority queue with explicit item ownership.
func NewWithBudget ¶
NewWithBudget returns an empty queue sharing an aggregate retention budget.
func NewWithClock ¶
NewWithClock returns an empty queue using now for deterministic deadline decisions.
func (*Queue[T]) Close ¶
func (q *Queue[T]) Close()
Close rejects future pushes and wakes blocked consumers.
func (*Queue[T]) Pop ¶
Pop waits for and transfers ownership of the next unexpired item to the caller.
func (*Queue[T]) Ready ¶
func (q *Queue[T]) Ready() <-chan struct{}
Ready returns a coalesced notification for newly queued work.