mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Use time_sleep_until() instead of usleep(), improved thread kill
This commit is contained in:
@ -466,20 +466,10 @@ namespace pocketmine {
|
||||
|
||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
||||
if($thread->isRunning()){
|
||||
$logger->debug("Stopping " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
if($thread instanceof Thread){
|
||||
$thread->kill();
|
||||
sleep(1);
|
||||
if($thread->isRunning()){
|
||||
$thread->detach();
|
||||
}
|
||||
}elseif($thread instanceof Worker){
|
||||
$thread->kill();
|
||||
sleep(1);
|
||||
if($thread->isRunning()){
|
||||
$thread->detach();
|
||||
}
|
||||
}
|
||||
$logger->debug("Killing " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
$thread->kill();
|
||||
sleep(1);
|
||||
$thread->detach();
|
||||
}elseif(!$thread->isJoined()){
|
||||
if(!$thread->isTerminated()){
|
||||
$logger->debug("Joining " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
@ -487,6 +477,7 @@ namespace pocketmine {
|
||||
}else{
|
||||
$logger->debug("Killing " . (new \ReflectionClass($thread))->getShortName() . " thread");
|
||||
$thread->kill();
|
||||
$thread->detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user