Scheduler: shutdown async pool properly instead of relying on ThreadManager

This commit is contained in:
Dylan K. Taylor 2018-05-09 19:49:12 +01:00
parent 05f4262e81
commit c9bd60123b
3 changed files with 16 additions and 3 deletions

View File

@ -2046,9 +2046,8 @@ class Server{
HandlerList::unregisterAll();
if($this->scheduler instanceof ServerScheduler){
$this->getLogger()->debug("Stopping all tasks");
$this->scheduler->cancelAllTasks();
$this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
$this->getLogger()->debug("Shutting down task scheduler");
$this->scheduler->shutdown();
}
if($this->properties !== null and $this->properties->hasChanged()){

View File

@ -183,4 +183,13 @@ class AsyncPool{
Timings::$schedulerAsyncTimer->stopTiming();
}
public function shutdown() : void{
$this->collectTasks();
$this->removeTasks();
foreach($this->workers as $worker){
$worker->quit();
}
$this->workers = [];
}
}

View File

@ -310,6 +310,11 @@ class ServerScheduler{
return $handler;
}
public function shutdown() : void{
$this->cancelAllTasks();
$this->asyncPool->shutdown();
}
/**
* @param int $currentTick
*/