Pull requests
- fix(pool): avoid race conditions when a task is submitted while the pool is stopping by @alitto in https://github.com/alitto/pond/pull/105
- feat(pool): add non-blocking submission methods and dropped tasks metric by @alitto in https://github.com/alitto/pond/pull/107
Changes
- Ensure
closedatomic 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
trySubmitmethod to make it simpler and more clear. - Centralize worker launch in a new method called
launchWorker. - Replace
subpoolSubmitwithsubpoolWorkermethod. - Add methods to submit individual tasks in a non-blocking fashion (
TrySubmitandTrySubmitErr). Requested in https://github.com/alitto/pond/issues/103 - Expose new
DroppedTasksmetric that reflects the number of tasks that were not executed because the queue was full. Issue reported in https://github.com/alitto/pond/issues/100 SubmittedTasksmetric now includes dropped tasks and it stops being updated once the pool is stopped.
Fixes
- Decrement
workerCountcounter when the pool context is cancelled. Resize()now supports settingmaxConcurrencyto 0 (no limit)
Full Changelog: https://github.com/alitto/pond/compare/v2.3.0...v2.3.1