pool

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pool provides a true worker pool implementation with job queue and context support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

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

Job represents a unit of work to be executed by the pool

type Pool

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

Pool represents a pool of workers with a job queue

func NewPool

func NewPool(maxWorkers int, queueSize int) *Pool

NewPool creates a new worker pool with job queue

func (*Pool) IsShuttingDown

func (p *Pool) IsShuttingDown() bool

IsShuttingDown returns true if the pool is shutting down

func (*Pool) MaxWorkers

func (p *Pool) MaxWorkers() int

MaxWorkers returns the number of workers

func (*Pool) QueueCapacity

func (p *Pool) QueueCapacity() int

QueueCapacity returns the maximum queue capacity

func (*Pool) QueueSize

func (p *Pool) QueueSize() int

QueueSize returns the current number of jobs in the queue

func (*Pool) Shutdown

func (p *Pool) Shutdown(timeout time.Duration) error

Shutdown gracefully shuts down the pool

func (*Pool) Submit

func (p *Pool) Submit(ctx context.Context, fn func() error) error

Submit adds a job to the queue (non-blocking) Returns error if the queue is full or pool is shutting down

Jump to

Keyboard shortcuts

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