mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Scheduler: shutdown async pool properly instead of relying on ThreadManager
This commit is contained in:
parent
05f4262e81
commit
c9bd60123b
@ -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()){
|
||||
|
@ -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 = [];
|
||||
}
|
||||
}
|
||||
|
@ -310,6 +310,11 @@ class ServerScheduler{
|
||||
return $handler;
|
||||
}
|
||||
|
||||
public function shutdown() : void{
|
||||
$this->cancelAllTasks();
|
||||
$this->asyncPool->shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $currentTick
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user