Release v2.3.1
Pull requests
- fix(pool): avoid race conditions when a task is submitted while the pool is stopping by @alitto in #105
- feat(pool): add non-blocking submission methods and dropped tasks metric by @alitto in #107
Changes
- Ensure
closed
atomic bool is toggled and checked while holding the mutex to avoid race conditions. - Ensure
workersWaitGroup.Add()
is always called while holding the mutex to avoid race conditions. - Improve comments on submit methods to clarify the behavior when the pool is stopped.
- Refactor
trySubmit
method to make it simpler and more clear. - Centralize worker launch in a new method called
launchWorker
. - Replace
subpoolSubmit
withsubpoolWorker
method. - Add methods to submit individual tasks in a non-blocking fashion (
TrySubmit
andTrySubmitErr
). Requested in #103 - Expose new
DroppedTasks
metric that reflects the number of tasks that were not executed because the queue was full. Issue reported in #100 SubmittedTasks
metric now includes dropped tasks and it stops being updated once the pool is stopped.
Fixes
- Decrement
workerCount
counter when the pool context is cancelled. Resize()
now supports settingmaxConcurrency
to 0 (no limit)
Full Changelog: v2.3.0...v2.3.1