Changed how exceptions work and are logged, throw proper exceptions on tasks

This commit is contained in:
Shoghi Cervantes
2015-09-18 12:03:24 +02:00
parent 472fcfa4c7
commit 0bcf639a98
15 changed files with 52 additions and 78 deletions

View File

@ -25,6 +25,14 @@ use pocketmine\Worker;
class AsyncWorker extends Worker{
private $logger;
private $id;
public function __construct(\ThreadedLogger $logger, $id){
$this->logger = $logger;
$this->id = $id;
}
public function run(){
$this->registerClassLoader();
gc_enable();
@ -32,14 +40,13 @@ class AsyncWorker extends Worker{
global $store;
$store = [];
}
public function start(int $options = PTHREADS_INHERIT_NONE){
parent::start(PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_FUNCTIONS);
public function handleException(\Throwable $e){
$this->logger->logException($e);
}
public function getThreadName(){
return "Asynchronous Worker";
return "Asynchronous Worker #" . $this->id;
}
}