mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 09:26:06 +00:00
Improved memory output, logging, removed locks
This commit is contained in:
@ -25,10 +25,6 @@
|
||||
namespace pocketmine\utils;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
/**
|
||||
* WARNING: This class is available on the PocketMine-MP Zephir project.
|
||||
* If this class is modified, remember to modify the PHP C extension.
|
||||
*/
|
||||
class Binary{
|
||||
const BIG_ENDIAN = 0x00;
|
||||
const LITTLE_ENDIAN = 0x01;
|
||||
|
@ -47,7 +47,7 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
$this->logFile = $logFile;
|
||||
$this->logDebug = (bool) $logDebug;
|
||||
$this->logStream = "";
|
||||
$this->start(PTHREADS_INHERIT_NONE);
|
||||
$this->start();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,7 +190,11 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
$this->attachment->call($level, $message);
|
||||
}
|
||||
|
||||
$this->logStream .= date("Y-m-d", $now) . " " . $cleanMessage;
|
||||
$str = date("Y-m-d", $now) . " " . $cleanMessage . "\n";
|
||||
$this->synchronized(function($str){
|
||||
$this->logStream .= $str;
|
||||
$this->notify();
|
||||
}, $str);
|
||||
}
|
||||
|
||||
public function run(){
|
||||
@ -201,15 +205,15 @@ class MainLogger extends \AttachableThreadedLogger{
|
||||
}
|
||||
|
||||
while($this->shutdown === false){
|
||||
if(strlen($this->logStream) > 0){
|
||||
$this->lock();
|
||||
$chunk = $this->logStream;
|
||||
$this->logStream = "";
|
||||
$this->unlock();
|
||||
fwrite($this->logResource, $chunk);
|
||||
}else{
|
||||
usleep(250000);
|
||||
}
|
||||
$this->synchronized(function(){
|
||||
if(strlen($this->logStream) > 0){
|
||||
$chunk = $this->logStream;
|
||||
$this->logStream = "";
|
||||
fwrite($this->logResource, $chunk);
|
||||
}else{
|
||||
$this->wait(250000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(strlen($this->logStream) > 0){
|
||||
|
@ -24,8 +24,6 @@ namespace pocketmine\utils;
|
||||
|
||||
/**
|
||||
* Unsecure Random Number Noise, used for fast seeded values
|
||||
* WARNING: This class is available on the PocketMine-MP Zephir project.
|
||||
* If this class is modified, remember to modify the PHP C extension.
|
||||
*/
|
||||
class Random{
|
||||
|
||||
|
@ -70,9 +70,9 @@ abstract class TextFormat{
|
||||
*/
|
||||
public static function clean($string, $removeFormat = true){
|
||||
if($removeFormat){
|
||||
return preg_replace(["/§[0123456789abcdefklmnor]/", "/\x1b\\[[0-9;]+m/"], "", $string);
|
||||
return preg_replace(["/§[0123456789abcdefklmnor]/", "/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/"], "", $string);
|
||||
}
|
||||
return preg_replace("/\x1b\\[[0-9;]+m/", "", $string);
|
||||
return preg_replace("/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/", "", $string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user