Versions in this module Expand all Collapse all v0 v0.0.2 Jul 6, 2022 v0.0.1 Jul 6, 2022 Changes in this version + var ErrAlreadyEnded = errors.New("already ended") + var ErrAlreadyStarted = errors.New("already started") + type Option = func(w *WorkerPool) *WorkerPool + func SetAbnormalReturnCb(cb func(err error)) Option + func SetDefaultAbnormalReturnCb() Option + func SetDefaultWorkerConstructor(workCh chan WorkFn, onTaskReceived func(), onTaskDone func()) Option + func SetWorkerConstructor(workCh chan WorkFn, workerConstructor WorkerConstructor) Option + type WorkFn = func(ctx context.Context) + type Worker struct + func NewWorker(id T, workCh <-chan WorkFn, taskReceived, taskDone func()) (*Worker[T], error) + func (w *Worker[T]) Id() T + func (w *Worker[T]) Kill() + func (w *Worker[T]) Start() (err error) + func (w *Worker[T]) Stop() + type WorkerConstructor = func(id int, onTaskReceived func(), onTaskDone func()) *Worker[int] + func BuildWorkerConstructor(workCh <-chan WorkFn, onTaskReceived_ func(), onTaskDone_ func()) WorkerConstructor + type WorkerPool struct + func NewWorkerPool(options ...Option) *WorkerPool + func (p *WorkerPool) ActiveWorkerNum() int64 + func (p *WorkerPool) Add(delta uint32) (newAliveLen int) + func (p *WorkerPool) Kill() + func (p *WorkerPool) Len() (alive int, sleeping int) + func (p *WorkerPool) Remove(delta uint32) (alive int, sleeping int) + func (p *WorkerPool) Send(workFn WorkFn) + func (p *WorkerPool) SenderChan() chan<- WorkFn + func (p *WorkerPool) Wait()