workerpool

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package workerpool provides a fixed-size goroutine pool with blocking submit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a fixed-size goroutine pool. Submit blocks when all workers are busy, providing natural backpressure.

func New

func New(size int) *Pool

New creates a fixed-size goroutine pool with size workers. The internal queue capacity equals size — Submit blocks when all workers busy.

func (*Pool) Close

func (p *Pool) Close()

Close stops accepting new tasks and waits for all in-flight tasks to complete.

func (*Pool) Submit

func (p *Pool) Submit(fn Task)

Submit enqueues a task. Blocks until a worker is available, providing backpressure.

type Task

type Task func(ctx context.Context) error

Task is a unit of work executed by the pool.

Jump to

Keyboard shortcuts

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