worklist

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package worklist provides a thread-safe work queue for distributing file paths to concurrent workers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Path string
}

Entry represents a single work item containing a file path to process.

func NewEntry added in v1.1.0

func NewEntry(path string) Entry

NewEntry creates a new work entry with the given file path.

type Worklist

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

Worklist is a thread-safe queue for distributing work entries to multiple workers. It is safe for concurrent use by multiple goroutines.

func New

func New(bufferSize int) *Worklist

New creates a new Worklist with the specified buffer size.

func (*Worklist) Add

func (w *Worklist) Add(work Entry)

Add adds a work entry to the worklist. This will block if the buffer is full.

func (*Worklist) Cap added in v1.1.0

func (w *Worklist) Cap() int

Cap returns the buffer capacity of the worklist.

func (*Worklist) Close added in v1.1.0

func (w *Worklist) Close()

Close closes the worklist channel, signaling that no more work will be added. Workers should drain remaining items before exiting.

func (*Worklist) Len added in v1.1.0

func (w *Worklist) Len() int

Len returns the approximate number of pending jobs in the worklist. This value may change immediately after calling.

func (*Worklist) Next

func (w *Worklist) Next() (Entry, bool)

Next retrieves the next work entry from the worklist. Returns false if the channel is closed and empty.

func (*Worklist) NextWithContext added in v1.1.0

func (w *Worklist) NextWithContext(ctx context.Context) (Entry, bool)

NextWithContext retrieves the next work entry or returns early if context is cancelled.

Jump to

Keyboard shortcuts

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