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.
This commit is contained in:
Dylan K. Taylor 2021-02-04 15:07:40 +00:00
parent eaf3a86981
commit 8ef1e54e20
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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();
});
}