Worker: Unstack tasks in a synchronized block

this prevents any tasks still left in the queue on shutdown getting pulled out by the worker when we're attempting to shut it down.
This led to various race conditions, most notably weird cases where PopulationTask would inexplicably find its expected generator state had not been correctly set up.
This commit is contained in:
Dylan K. Taylor 2022-08-21 21:57:11 +01:00
parent d144832928
commit f75ca312cc
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -56,7 +56,9 @@ abstract class Worker extends \Worker{
$this->isKilled = true;
if(!$this->isShutdown()){
while($this->unstack() !== null);
$this->synchronized(function() : void{
while($this->unstack() !== null);
});
$this->notify();
$this->shutdown();
}