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 (*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.
Click to show internal directories.
Click to hide internal directories.