From 8ef1e54e200a2d9184bf98f114ed11463f0e47c8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 4 Feb 2021 15:07:40 +0000 Subject: [PATCH] MainLogger: fixing CPU waste on logger thread this doesn't need to keep spinning every 25ms; it can just wake up when there's actually log messages to write into the buffer. --- src/pocketmine/utils/MainLogger.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index adf4c61ff..ce97ac373 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -321,6 +321,7 @@ class MainLogger extends \AttachableThreadedLogger{ } $this->logStream[] = $time->format("Y-m-d") . " " . TextFormat::clean($message) . PHP_EOL; + $this->notify(); }); } @@ -367,7 +368,7 @@ class MainLogger extends \AttachableThreadedLogger{ while(!$this->shutdown){ $this->writeLogStream($logResource); $this->synchronized(function() : void{ - $this->wait(25000); + $this->wait(); }); }