AsyncPool: Do not drop pending tasks on shutdown

this creates an extra element of uncertainty for async pool usage.
This commit is contained in:
Dylan K. Taylor 2021-06-11 18:30:00 +01:00
parent f245147c11
commit 22b5e5db5e
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -313,20 +313,8 @@ class AsyncPool{
* Cancels all pending tasks and shuts down all the workers in the pool.
*/
public function shutdown() : void{
$this->collectTasks();
foreach($this->workers as $worker){
/** @var AsyncTask $task */
while(($task = $worker->unstack()) !== null){
//NOOP: the below loop will deal with marking tasks as garbage
}
}
foreach($this->taskQueues as $queue){
while(!$queue->isEmpty()){
/** @var AsyncTask $task */
$task = $queue->dequeue();
$task->cancelRun();
}
while($this->collectTasks()){
//NOOP
}
foreach($this->workers as $worker){