Improved memory output, logging, removed locks

This commit is contained in:
Shoghi Cervantes
2015-03-22 03:20:48 +01:00
parent d2bf92c3ed
commit 1666602652
7 changed files with 34 additions and 41 deletions

View File

@ -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;

View File

@ -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){

View File

@ -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{

View File

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