mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +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->shutdown();
|
||||||
$logger->join();
|
$logger->join();
|
||||||
|
|
||||||
$killer->kill();
|
|
||||||
|
|
||||||
echo Terminal::$FORMAT_RESET . "\n";
|
echo Terminal::$FORMAT_RESET . "\n";
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -1970,7 +1970,7 @@ class Server{
|
|||||||
|
|
||||||
$this->getLogger()->debug("Closing console");
|
$this->getLogger()->debug("Closing console");
|
||||||
$this->console->shutdown();
|
$this->console->shutdown();
|
||||||
$this->console->kill();
|
$this->console->notify();
|
||||||
|
|
||||||
$this->getLogger()->debug("Stopping network interfaces");
|
$this->getLogger()->debug("Stopping network interfaces");
|
||||||
foreach($this->network->getInterfaces() as $interface){
|
foreach($this->network->getInterfaces() as $interface){
|
||||||
|
@ -28,6 +28,7 @@ abstract class Thread extends \Thread{
|
|||||||
|
|
||||||
/** @var \ClassLoader */
|
/** @var \ClassLoader */
|
||||||
protected $classLoader;
|
protected $classLoader;
|
||||||
|
protected $isKilled = false;
|
||||||
|
|
||||||
public function getClassLoader(){
|
public function getClassLoader(){
|
||||||
return $this->classLoader;
|
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.
|
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
|
||||||
*/
|
*/
|
||||||
public function quit(){
|
public function quit(){
|
||||||
if($this->isRunning()){
|
$this->isKilled = true;
|
||||||
$this->kill();
|
|
||||||
}elseif(!$this->isJoined()){
|
$this->notify();
|
||||||
|
|
||||||
|
if(!$this->isJoined()){
|
||||||
if(!$this->isTerminated()){
|
if(!$this->isTerminated()){
|
||||||
$this->join();
|
$this->join();
|
||||||
}else{
|
|
||||||
$this->kill();
|
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
$this->kill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadManager::getInstance()->remove($this);
|
ThreadManager::getInstance()->remove($this);
|
||||||
|
@ -42,7 +42,7 @@ class ThreadManager extends \Volatile{
|
|||||||
*/
|
*/
|
||||||
public function add($thread){
|
public function add($thread){
|
||||||
if($thread instanceof Thread or $thread instanceof Worker){
|
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){
|
public function remove($thread){
|
||||||
if($thread instanceof Thread or $thread instanceof Worker){
|
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 */
|
/** @var \ClassLoader */
|
||||||
protected $classLoader;
|
protected $classLoader;
|
||||||
|
|
||||||
|
protected $isKilled = false;
|
||||||
|
|
||||||
public function getClassLoader(){
|
public function getClassLoader(){
|
||||||
return $this->classLoader;
|
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.
|
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
|
||||||
*/
|
*/
|
||||||
public function quit(){
|
public function quit(){
|
||||||
|
$this->isKilled = true;
|
||||||
|
|
||||||
|
$this->notify();
|
||||||
|
|
||||||
if($this->isRunning()){
|
if($this->isRunning()){
|
||||||
|
$this->shutdown();
|
||||||
|
$this->notify();
|
||||||
$this->unstack();
|
$this->unstack();
|
||||||
$this->kill();
|
|
||||||
}elseif(!$this->isJoined()){
|
}elseif(!$this->isJoined()){
|
||||||
if(!$this->isTerminated()){
|
if(!$this->isTerminated()){
|
||||||
$this->join();
|
$this->join();
|
||||||
}else{
|
|
||||||
$this->kill();
|
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
$this->kill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadManager::getInstance()->remove($this);
|
ThreadManager::getInstance()->remove($this);
|
||||||
|
@ -87,6 +87,10 @@ class PluginLogger implements \AttachableLogger{
|
|||||||
$this->log(LogLevel::DEBUG, $message);
|
$this->log(LogLevel::DEBUG, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function logException(\Throwable $e, $trace = null){
|
||||||
|
Server::getInstance()->getLogger()->logException($e, $trace);
|
||||||
|
}
|
||||||
|
|
||||||
public function log($level, $message){
|
public function log($level, $message){
|
||||||
Server::getInstance()->getLogger()->log($level, $this->pluginName . $message);
|
Server::getInstance()->getLogger()->log($level, $this->pluginName . $message);
|
||||||
foreach($this->attachments as $attachment){
|
foreach($this->attachments as $attachment){
|
||||||
|
@ -47,7 +47,7 @@ class AsyncPool{
|
|||||||
|
|
||||||
for($i = 0; $i < $this->size; ++$i){
|
for($i = 0; $i < $this->size; ++$i){
|
||||||
$this->workerUsage[$i] = 0;
|
$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]->setClassLoader($this->server->getLoader());
|
||||||
$this->workers[$i]->start();
|
$this->workers[$i]->start();
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class AsyncPool{
|
|||||||
if($newSize > $this->size){
|
if($newSize > $this->size){
|
||||||
for($i = $this->size; $i < $newSize; ++$i){
|
for($i = $this->size; $i < $newSize; ++$i){
|
||||||
$this->workerUsage[$i] = 0;
|
$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]->setClassLoader($this->server->getLoader());
|
||||||
$this->workers[$i]->start();
|
$this->workers[$i]->start();
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,15 @@ class ServerKiller extends Thread{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function run(){
|
public function run(){
|
||||||
|
$start = time() + 1;
|
||||||
$this->synchronized(function(){
|
$this->synchronized(function(){
|
||||||
$this->wait($this->time * 1000000);
|
$this->wait($this->time * 1000000);
|
||||||
});
|
});
|
||||||
|
if(time() - $start >= $this->time){
|
||||||
echo "\nTook too long to stop, server was killed forcefully!\n";
|
echo "\nTook too long to stop, server was killed forcefully!\n";
|
||||||
@\pocketmine\kill(getmypid());
|
@\pocketmine\kill(getmypid());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getThreadName(){
|
public function getThreadName(){
|
||||||
return "Server Killer";
|
return "Server Killer";
|
||||||
|
@ -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