Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchProcessorFunc ¶
type BatchProcessorFunc func(Job)
BatchProcessorFunc represents a function that processes a job
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool represents a pool of workers
func NewWorkerPool ¶
func NewWorkerPool(batchProcessor BatchProcessorFunc, numWorkers int) *WorkerPool
NewWorkerPool initializes a new worker pool with a job generator function Parameters: - batchProcessor: The function that processes a batch of jobs. - numWorkers: The number of workers in the pool. Returns: - A pointer to the initialized WorkerPool.
func (*WorkerPool) AddJob ¶
func (pool *WorkerPool) AddJob(job Job) error
AddJob adds a job to the worker pool Parameters: - job: The job to be added to the pool. Returns: - An error if the pool is closed, nil otherwise.
func (*WorkerPool) Wait ¶
func (pool *WorkerPool) Wait()
Wait waits for all jobs to complete Closes the job queue and sets the pool to closed to prevent further job additions.
Click to show internal directories.
Click to hide internal directories.