queue

package
v3.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package queue provides a sequential, non-blocking, unbounded task execution queue. It mimics Node.js's event loop and is deeply inspired by Kubernetes workqueue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue serializes function execution through a single goroutine. It uses an unbounded slice backed by a condition variable to ensure Enqueue never blocks the caller.

func New

func New() *Queue

New creates a new Queue and starts the internal consumer goroutine.

func (*Queue) Close

func (q *Queue) Close()

Close shuts down the Queue gracefully. It waits for all previously enqueued tasks to complete before returning.

func (*Queue) Enqueue

func (q *Queue) Enqueue(task func())

Enqueue adds a task to the queue for sequential execution. It returns immediately and NEVER blocks.

func (*Queue) IsShuttingDown

func (q *Queue) IsShuttingDown() bool

IsShuttingDown reports whether TryClose or Close has been called.

func (*Queue) Size

func (q *Queue) Size() int

Size returns the number of pending tasks in the queue.

func (*Queue) TryClose

func (q *Queue) TryClose()

TryClose shuts down the Queue without waiting for completion. Pending tasks are discarded.

Jump to

Keyboard shortcuts

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