queue

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FIFO

type FIFO[T any] struct {
	// contains filtered or unexported fields
}

FIFO is a bounded blocking queue optimized for immediate jobs. It uses a fixed-size circular buffer, no per-item allocation, and O(1) push/pop.

func NewFIFO

func NewFIFO[T any](capacity int) *FIFO[T]

func (*FIFO[T]) Cap

func (q *FIFO[T]) Cap() int

func (*FIFO[T]) Close

func (q *FIFO[T]) Close()

func (*FIFO[T]) Len

func (q *FIFO[T]) Len() int

func (*FIFO[T]) Pop

func (q *FIFO[T]) Pop() (T, bool)

func (*FIFO[T]) PopTimeout

func (q *FIFO[T]) PopTimeout(d time.Duration) (T, bool)

func (*FIFO[T]) Push

func (q *FIFO[T]) Push(v T) bool

func (*FIFO[T]) TryPop

func (q *FIFO[T]) TryPop() (T, bool)

func (*FIFO[T]) TryPush

func (q *FIFO[T]) TryPush(v T) bool

type Item

type Item[T any] struct {
	Value    T
	Priority int
	Seq      uint64
	RunAt    time.Time
}

type PriorityQueue

type PriorityQueue[T any] struct {
	// contains filtered or unexported fields
}

func NewPriorityQueue

func NewPriorityQueue[T any](capacity int) *PriorityQueue[T]

func (*PriorityQueue[T]) Cap

func (q *PriorityQueue[T]) Cap() int

func (*PriorityQueue[T]) Close

func (q *PriorityQueue[T]) Close()

func (*PriorityQueue[T]) Closed

func (q *PriorityQueue[T]) Closed() bool

func (*PriorityQueue[T]) DropOldestPush

func (q *PriorityQueue[T]) DropOldestPush(it Item[T]) bool

func (*PriorityQueue[T]) DropOldestPushValue

func (q *PriorityQueue[T]) DropOldestPushValue(it Item[T]) (Item[T], bool, bool)

DropOldestPushValue inserts it and reports the item evicted to make room. The second return value is false when no item was evicted.

func (*PriorityQueue[T]) Len

func (q *PriorityQueue[T]) Len() int

func (*PriorityQueue[T]) Pop

func (q *PriorityQueue[T]) Pop() (Item[T], bool)

func (*PriorityQueue[T]) PopTimeout

func (q *PriorityQueue[T]) PopTimeout(timeout time.Duration) (Item[T], bool)

func (*PriorityQueue[T]) Push

func (q *PriorityQueue[T]) Push(it Item[T]) bool

func (*PriorityQueue[T]) TryPop

func (q *PriorityQueue[T]) TryPop() (Item[T], bool)

type Ring

type Ring[T any] struct {
	// contains filtered or unexported fields
}

Ring is a bounded MPMC ring buffer using sequence numbers. It is optimized for immediate FIFO jobs and exposed for users that need a very fast custom queue.

func NewRing

func NewRing[T any](size uint64) *Ring[T]

func (*Ring[T]) Cap

func (r *Ring[T]) Cap() uint64

func (*Ring[T]) Len

func (r *Ring[T]) Len() uint64

func (*Ring[T]) TryPop

func (r *Ring[T]) TryPop() (T, bool)

func (*Ring[T]) TryPush

func (r *Ring[T]) TryPush(v T) bool

Jump to

Keyboard shortcuts

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