taskqueue

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 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

Overview

Package taskqueue provides a small intrusive MPSC FIFO queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

Node is prepared by a producer before it enters the queue. Value is owned by the caller; the queue only links nodes.

func (*Node[T]) TakeNext

func (n *Node[T]) TakeNext() *Node[T]

TakeNext detaches and returns the next node in a drained private batch.

type Queue

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

Queue is a multi-producer, single-consumer FIFO. Its lock only protects acceptance state and pointer linkage.

func New

func New[T any]() *Queue[T]

New returns an accepting queue.

func (*Queue[T]) Accepting

func (q *Queue[T]) Accepting() bool

Accepting reports whether ordinary work may still be submitted.

func (*Queue[T]) Drain

func (q *Queue[T]) Drain() *Node[T]

Drain removes the complete public queue in O(1). The returned chain is private to the single consumer and remains in FIFO order.

func (*Queue[T]) HasPending

func (q *Queue[T]) HasPending() bool

HasPending reports whether public work is waiting.

func (*Queue[T]) Push

func (q *Queue[T]) Push(node *Node[T]) bool

Push appends node when the queue is still accepting work.

func (*Queue[T]) Stop

func (q *Queue[T]) Stop(node *Node[T]) bool

Stop atomically stops accepting ordinary work and appends the final node. It returns false when another producer already stopped the queue.

Jump to

Keyboard shortcuts

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