wp

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package wp provides a simple worker pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkerPool

type WorkerPool struct {
	// Number of concurrent workers (default: 1).
	// If negative, spawns a goroutine for each task.
	NumWorkers int
	// Task queue (default: buffered channel with 128 capacity).
	Tasks chan func()
	// contains filtered or unexported fields
}

WorkerPool manages a pool of goroutines that process tasks from a queue.

func New added in v0.1.1

func New() *WorkerPool

New creates and starts the default worker pool.

func (*WorkerPool) Close

func (p *WorkerPool) Close()

Close stops all the workers and waits for them to exit.

func (*WorkerPool) Drain

func (p *WorkerPool) Drain()

Drain closes Tasks channel and waits for the workers to process remaining tasks and exit.

func (*WorkerPool) Init

func (p *WorkerPool) Init()

Init initializes and starts the worker pool.

Jump to

Keyboard shortcuts

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