mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
AsyncPool: Always collect workers, even if the task queue is empty
because of the way async tasks are processed, we might collect results from a task before it's able to be collected by collect(). Therefore, the queue might be empty, even though there are still tasks to be collected.
This commit is contained in:
parent
27b1951df7
commit
54d9342ed9
@ -245,14 +245,12 @@ class AsyncPool{
|
||||
throw new \InvalidArgumentException("No such worker $worker");
|
||||
}
|
||||
$queue = $this->taskQueues[$worker];
|
||||
$doGC = false;
|
||||
$more = false;
|
||||
while(!$queue->isEmpty()){
|
||||
/** @var AsyncTask $task */
|
||||
$task = $queue->bottom();
|
||||
$task->checkProgressUpdates();
|
||||
if($task->isFinished()){ //make sure the task actually executed before trying to collect
|
||||
$doGC = true;
|
||||
$queue->dequeue();
|
||||
|
||||
if($task->isCrashed()){
|
||||
@ -276,9 +274,7 @@ class AsyncPool{
|
||||
break; //current task is still running, skip to next worker
|
||||
}
|
||||
}
|
||||
if($doGC){
|
||||
$this->workers[$worker]->collect();
|
||||
}
|
||||
$this->workers[$worker]->collect();
|
||||
return $more;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user