mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
Merge branch 'release/3.2'
This commit is contained in:
commit
b9769c407b
@ -67,29 +67,22 @@ abstract class Thread extends \Thread{
|
|||||||
public function start(?int $options = \PTHREADS_INHERIT_ALL){
|
public function start(?int $options = \PTHREADS_INHERIT_ALL){
|
||||||
ThreadManager::getInstance()->add($this);
|
ThreadManager::getInstance()->add($this);
|
||||||
|
|
||||||
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
|
||||||
if($this->getClassLoader() === null){
|
if($this->getClassLoader() === null){
|
||||||
$this->setClassLoader();
|
$this->setClassLoader();
|
||||||
}
|
}
|
||||||
return parent::start($options);
|
return parent::start($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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->isKilled = true;
|
||||||
|
|
||||||
$this->notify();
|
|
||||||
|
|
||||||
if(!$this->isJoined()){
|
if(!$this->isJoined()){
|
||||||
if(!$this->isTerminated()){
|
$this->notify();
|
||||||
$this->join();
|
$this->join();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ThreadManager::getInstance()->remove($this);
|
ThreadManager::getInstance()->remove($this);
|
||||||
}
|
}
|
||||||
|
@ -67,32 +67,22 @@ abstract class Worker extends \Worker{
|
|||||||
public function start(?int $options = \PTHREADS_INHERIT_ALL){
|
public function start(?int $options = \PTHREADS_INHERIT_ALL){
|
||||||
ThreadManager::getInstance()->add($this);
|
ThreadManager::getInstance()->add($this);
|
||||||
|
|
||||||
if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){
|
|
||||||
if($this->getClassLoader() === null){
|
if($this->getClassLoader() === null){
|
||||||
$this->setClassLoader();
|
$this->setClassLoader();
|
||||||
}
|
}
|
||||||
return parent::start($options);
|
return parent::start($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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->isKilled = true;
|
||||||
|
|
||||||
$this->notify();
|
|
||||||
|
|
||||||
if($this->isRunning()){
|
if($this->isRunning()){
|
||||||
$this->shutdown();
|
while($this->unstack() !== null);
|
||||||
$this->notify();
|
$this->notify();
|
||||||
$this->unstack();
|
$this->shutdown();
|
||||||
}elseif(!$this->isJoined()){
|
|
||||||
if(!$this->isTerminated()){
|
|
||||||
$this->join();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadManager::getInstance()->remove($this);
|
ThreadManager::getInstance()->remove($this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user