workerpool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkerPool

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

WorkerPool dispatches jobs to a fixed set of worker goroutines.

A pool created with a non-positive number of workers is degenerate: it never starts any worker and Do executes the job inline, in the caller goroutine. The same fallback applies after Stop has been called.

func NewWP

func NewWP(nWorkers int) *WorkerPool

func (*WorkerPool) Do

func (wp *WorkerPool) Do(job func())

Do enqueues a job. Once the pool is stopped (or was created without workers), the job runs inline in the calling goroutine.

func (*WorkerPool) Run

func (wp *WorkerPool) Run()

func (*WorkerPool) Stop

func (wp *WorkerPool) Stop()

Stop stops accepting new jobs, waits for already queued and in-flight jobs to finish, and then releases the workers. It is safe to call more than once.

Jump to

Keyboard shortcuts

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