mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
Some minor cleanup of PocketMine.php
This commit is contained in:
parent
be27e03126
commit
c283d87494
@ -558,19 +558,7 @@ namespace pocketmine {
|
|||||||
$killer->start();
|
$killer->start();
|
||||||
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
|
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
|
||||||
|
|
||||||
$erroredThreads = 0;
|
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||||
foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
|
|
||||||
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
|
|
||||||
try{
|
|
||||||
$thread->quit();
|
|
||||||
$logger->debug($thread->getThreadName() . " thread stopped successfully.");
|
|
||||||
}catch(\ThreadException $e){
|
|
||||||
++$erroredThreads;
|
|
||||||
$logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($erroredThreads > 0){
|
|
||||||
if(\pocketmine\DEBUG > 1){
|
if(\pocketmine\DEBUG > 1){
|
||||||
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
|
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine;
|
namespace pocketmine;
|
||||||
|
|
||||||
|
use pocketmine\utils\MainLogger;
|
||||||
|
|
||||||
class ThreadManager extends \Volatile{
|
class ThreadManager extends \Volatile{
|
||||||
|
|
||||||
/** @var ThreadManager */
|
/** @var ThreadManager */
|
||||||
@ -68,4 +70,23 @@ class ThreadManager extends \Volatile{
|
|||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function stopAll() : int{
|
||||||
|
$logger = MainLogger::getLogger();
|
||||||
|
|
||||||
|
$erroredThreads = 0;
|
||||||
|
|
||||||
|
foreach($this->getAll() as $thread){
|
||||||
|
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
|
||||||
|
try{
|
||||||
|
$thread->quit();
|
||||||
|
$logger->debug($thread->getThreadName() . " thread stopped successfully.");
|
||||||
|
}catch(\ThreadException $e){
|
||||||
|
++$erroredThreads;
|
||||||
|
$logger->debug("Could not stop " . $thread->getThreadName() . " thread: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $erroredThreads;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user