Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Task ¶
type Task[T any] interface { Run() T }
Task is interface for any job executed by the worker pool
type WorkerPool ¶
type WorkerPool[T any] struct { // contains filtered or unexported fields }
func NewWorkerPool ¶
func NewWorkerPool[T any](maxWorkers int, capacity int) *WorkerPool[T]
func (*WorkerPool[T]) Enqueue ¶ added in v1.2.53
func (q *WorkerPool[T]) Enqueue(task Task[T]) bool
Enqueue submits a task to the buffered job queue without blocking, returns false if queue is full
func (*WorkerPool[T]) EnqueueWithTimeout ¶ added in v1.2.53
func (q *WorkerPool[T]) EnqueueWithTimeout(task Task[T], timeout time.Duration) bool
EnqueueWithTimeout submits a task to the buffered job queue without blocking, returns false if queue is full within the duration
func (*WorkerPool[T]) Start ¶ added in v1.2.53
func (q *WorkerPool[T]) Start(callback func(T)) error
Start pool with optional callback to be invoked on task completion
func (*WorkerPool[T]) Stop ¶ added in v1.2.53
func (q *WorkerPool[T]) Stop()
func (*WorkerPool[T]) Submit ¶ added in v1.2.53
func (q *WorkerPool[T]) Submit(task Task[T])
Submit a task to the job queue, blocked if no workers are available
Click to show internal directories.
Click to hide internal directories.