Updated to new pthreads version, updated RakLib

This commit is contained in:
Shoghi Cervantes 2015-09-27 13:37:27 +02:00
parent 0bcf639a98
commit ddc140af5e
10 changed files with 33 additions and 26 deletions

View File

@ -473,8 +473,6 @@ namespace pocketmine {
$logger->shutdown();
$logger->join();
$killer->kill();
echo Terminal::$FORMAT_RESET . "\n";

View File

@ -1970,7 +1970,7 @@ class Server{
$this->getLogger()->debug("Closing console");
$this->console->shutdown();
$this->console->kill();
$this->console->notify();
$this->getLogger()->debug("Stopping network interfaces");
foreach($this->network->getInterfaces() as $interface){

View File

@ -28,6 +28,7 @@ abstract class Thread extends \Thread{
/** @var \ClassLoader */
protected $classLoader;
protected $isKilled = false;
public function getClassLoader(){
return $this->classLoader;
@ -68,16 +69,14 @@ abstract class Thread extends \Thread{
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
if($this->isRunning()){
$this->kill();
}elseif(!$this->isJoined()){
$this->isKilled = true;
$this->notify();
if(!$this->isJoined()){
if(!$this->isTerminated()){
$this->join();
}else{
$this->kill();
}
}else{
$this->kill();
}
ThreadManager::getInstance()->remove($this);
@ -86,4 +85,4 @@ abstract class Thread extends \Thread{
public function getThreadName(){
return (new \ReflectionClass($this))->getShortName();
}
}
}

View File

@ -42,7 +42,7 @@ class ThreadManager extends \Volatile{
*/
public function add($thread){
if($thread instanceof Thread or $thread instanceof Worker){
$this->{$thread->getThreadId()} = $thread;
$this->{spl_object_hash($thread)} = $thread;
}
}
@ -51,7 +51,7 @@ class ThreadManager extends \Volatile{
*/
public function remove($thread){
if($thread instanceof Thread or $thread instanceof Worker){
unset($this->{$thread->getThreadId()});
unset($this->{spl_object_hash($thread)});
}
}

View File

@ -28,6 +28,8 @@ abstract class Worker extends \Worker{
/** @var \ClassLoader */
protected $classLoader;
protected $isKilled = false;
public function getClassLoader(){
return $this->classLoader;
@ -68,17 +70,18 @@ abstract class Worker extends \Worker{
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
$this->isKilled = true;
$this->notify();
if($this->isRunning()){
$this->shutdown();
$this->notify();
$this->unstack();
$this->kill();
}elseif(!$this->isJoined()){
if(!$this->isTerminated()){
$this->join();
}else{
$this->kill();
}
}else{
$this->kill();
}
ThreadManager::getInstance()->remove($this);
@ -87,4 +90,4 @@ abstract class Worker extends \Worker{
public function getThreadName(){
return (new \ReflectionClass($this))->getShortName();
}
}
}

View File

@ -87,10 +87,14 @@ class PluginLogger implements \AttachableLogger{
$this->log(LogLevel::DEBUG, $message);
}
public function logException(\Throwable $e, $trace = null){
Server::getInstance()->getLogger()->logException($e, $trace);
}
public function log($level, $message){
Server::getInstance()->getLogger()->log($level, $this->pluginName . $message);
foreach($this->attachments as $attachment){
$attachment->log($level, $message);
}
}
}
}

View File

@ -47,7 +47,7 @@ class AsyncPool{
for($i = 0; $i < $this->size; ++$i){
$this->workerUsage[$i] = 0;
$this->workers[$i] = new AsyncWorker($this->server->getLogger(), $i);
$this->workers[$i] = new AsyncWorker($this->server->getLogger(), $i + 1);
$this->workers[$i]->setClassLoader($this->server->getLoader());
$this->workers[$i]->start();
}
@ -62,7 +62,7 @@ class AsyncPool{
if($newSize > $this->size){
for($i = $this->size; $i < $newSize; ++$i){
$this->workerUsage[$i] = 0;
$this->workers[$i] = new AsyncWorker($this->server->getLogger(), $i);
$this->workers[$i] = new AsyncWorker($this->server->getLogger(), $i + 1);
$this->workers[$i]->setClassLoader($this->server->getLoader());
$this->workers[$i]->start();
}

View File

@ -32,11 +32,14 @@ class ServerKiller extends Thread{
}
public function run(){
$start = time() + 1;
$this->synchronized(function(){
$this->wait($this->time * 1000000);
});
echo "\nTook too long to stop, server was killed forcefully!\n";
@\pocketmine\kill(getmypid());
if(time() - $start >= $this->time){
echo "\nTook too long to stop, server was killed forcefully!\n";
@\pocketmine\kill(getmypid());
}
}
public function getThreadName(){

@ -1 +1 @@
Subproject commit f6f207b9e47dc6fdb23b9e39dfcbabb545be9cd0
Subproject commit a5cca45a922ca193a616069f885866efc7158c67

@ -1 +1 @@
Subproject commit 3cd1f13c5d4937a5de1978d1950589082df760d2
Subproject commit 6edaf9802cbada5e7638ceadfe042be9921376d8