mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Updated to new pthreads version, updated RakLib
This commit is contained in:
parent
0bcf639a98
commit
ddc140af5e
@ -474,8 +474,6 @@ namespace pocketmine {
|
||||
$logger->shutdown();
|
||||
$logger->join();
|
||||
|
||||
$killer->kill();
|
||||
|
||||
echo Terminal::$FORMAT_RESET . "\n";
|
||||
|
||||
exit(0);
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
|
@ -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)});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,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,6 +87,10 @@ 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){
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
2
src/spl
2
src/spl
@ -1 +1 @@
|
||||
Subproject commit 3cd1f13c5d4937a5de1978d1950589082df760d2
|
||||
Subproject commit 6edaf9802cbada5e7638ceadfe042be9921376d8
|
Loading…
x
Reference in New Issue
Block a user