Added MemoryManager object watcher for object leak debugging, improved SPL Thread/Worker stopping, fixed some possible weak references crashing unexpectedly

This commit is contained in:
Shoghi Cervantes
2015-05-09 16:10:03 +02:00
parent 7e539ec85a
commit 1a1b8830a4
10 changed files with 158 additions and 30 deletions

View File

@ -63,4 +63,26 @@ abstract class Worker extends \Worker{
return false;
}
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
if($this->isRunning()){
$this->unstack();
$this->kill();
$this->detach();
}elseif(!$this->isJoined()){
if(!$this->isTerminated()){
$this->join();
}else{
$this->kill();
$this->detach();
}
}else{
$this->detach();
}
ThreadManager::getInstance()->remove($this);
}
}