mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-21 18:36:40 +00:00
Thread/Worker: Remove duplicated code
Despite the comments, there doesn't seem to be an obvious reason for these to be copy-pasted. Perhaps there was some legacy reason for this with legacy pthreads. In fact, it looks likely that quit() will probably be able to be traitified too.
This commit is contained in:
parent
fd1bc1b845
commit
03619ebca9
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\thread;
|
||||
|
||||
use pmmp\thread\Thread as NativeThread;
|
||||
use pmmp\thread\ThreadSafeArray;
|
||||
use pocketmine\errorhandler\ErrorToExceptionHandler;
|
||||
use pocketmine\Server;
|
||||
@ -96,6 +97,15 @@ trait CommonThreadPartsTrait{
|
||||
|
||||
public function getCrashInfo() : ?ThreadCrashInfo{ return $this->crashInfo; }
|
||||
|
||||
public function start(int $options = NativeThread::INHERIT_NONE) : bool{
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
if($this->getClassLoaders() === null){
|
||||
$this->setClassLoaders();
|
||||
}
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
final public function run() : void{
|
||||
error_reporting(-1);
|
||||
$this->registerClassLoaders();
|
||||
|
@ -38,16 +38,6 @@ use pocketmine\scheduler\AsyncTask;
|
||||
abstract class Thread extends NativeThread{
|
||||
use CommonThreadPartsTrait;
|
||||
|
||||
public function start(int $options = NativeThread::INHERIT_NONE) : bool{
|
||||
//this is intentionally not traitified
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
if($this->getClassLoaders() === null){
|
||||
$this->setClassLoaders();
|
||||
}
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
|
||||
*/
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\thread;
|
||||
|
||||
use pmmp\thread\Thread as NativeThread;
|
||||
use pmmp\thread\Worker as NativeWorker;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
|
||||
@ -40,16 +39,6 @@ use pocketmine\scheduler\AsyncTask;
|
||||
abstract class Worker extends NativeWorker{
|
||||
use CommonThreadPartsTrait;
|
||||
|
||||
public function start(int $options = NativeThread::INHERIT_NONE) : bool{
|
||||
//this is intentionally not traitified
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
||||
if($this->getClassLoaders() === null){
|
||||
$this->setClassLoaders();
|
||||
}
|
||||
return parent::start($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user