mirror of
https://github.com/XTXMarkets/ternfs.git
synced 2025-12-20 10:10:17 -06:00
_queuesWithWork can go negative. Consider the following scenario there are 2 queues first one has work and consumer is active. 1. producer adds work to queue 1 and sees it needs to update _queuesWithWork but is preempted 2. consumer consumes work from queue 0 and decrements _queuesWithWork to 0 3. consumer continues consuming and consumes all work from queue 1 4. consumer decrements _queuesWithWork to -1 5. only now producer updates _queuesWithWork to 0 It could be also solved by removeWork returning new value and then consumer stopping consumption if it is 0.