Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Task ¶
type Task interface {
Run() any
}
Task is interface for any job executed by the worker pool
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker type holds the job channel and passed worker threadpool
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool process all tasks
func NewWorkerPool ¶
func NewWorkerPool(workers int, size int, results chan any) *WorkerPool
NewWorkerPool factory method to create the worker pool with number of worker threads and limit the size of the task queue
func (*WorkerPool) Close ¶
func (t *WorkerPool) Close()
Close will close the worker pool and terminate all waiting jobs It sends the stop signal to all the worker that are running
func (*WorkerPool) Execute ¶
func (t *WorkerPool) Execute(task Task) error
Execute submits the job to the queue, return error if the queue is full
func (*WorkerPool) WaitForAll ¶
func (t *WorkerPool) WaitForAll()
WaitForAll for all jobs to complete
Click to show internal directories.
Click to hide internal directories.