Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JobQueue ¶
type JobQueue struct {
// contains filtered or unexported fields
}
JobQueue implements a background job processor using a single channel and wait group.
The channel is initialised with a maximum number of concurrent workers. Adding a new job consumes a worker from the channel. After finishing a job, the worker is added back to the channel. When all workers are consumed, adding new job will block.
Example usage:
jq := NewJobQueue(5) err := jq.Put(func() error { return nil }) errors.Join(err, jq.Collect())
func NewJobQueue ¶
Click to show internal directories.
Click to hide internal directories.