fix: protect worker node tasks queue from concurrent tasks stealing
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 13 Aug 2024 15:43:09 +0000 (17:43 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 13 Aug 2024 15:43:09 +0000 (17:43 +0200)
commiteebfd819241181d59144f45b51f566fca0211fc5
treee38fe61b8e5b66d8c9b9c57b5b7293f191a3b706
parentcfd2b9739df3e60a9627e9a703c9e7a9ee3c54ba
fix: protect worker node tasks queue from concurrent tasks stealing

The locking primitive is a mutex implemented with cheap boolean checks.
In a monothreaded JS runtime, it should be enough.

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts
src/pools/pool.ts
src/pools/worker-node.ts
src/pools/worker.ts
tests/pools/abstract-pool.test.mjs
tests/pools/worker-node.test.mjs