mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
AsyncTask: Rewrite how thread-local storage works, now non-dependent on Server or ServerScheduler
this implementation was god-awful bad and it was entirely avoidable to make it this complicated. This utilizes the fact that pthreads treats static properties as thread-local. AsyncTask local storage now utilizes a \SplObjectStorage stored in an AsyncTask private static field.
This commit is contained in:
@ -161,14 +161,14 @@ class AsyncPool{
|
||||
if(!$task->hasCancelledRun()){
|
||||
try{
|
||||
$task->onCompletion($this->server);
|
||||
if(!$this->server->getScheduler()->removeLocalComplex($task)){
|
||||
if($task->removeDanglingStoredObjects()){
|
||||
$this->server->getLogger()->notice("AsyncTask " . get_class($task) . " stored local complex data but did not remove them after completion");
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$this->server->getLogger()->critical("Could not execute completion of asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": " . $e->getMessage());
|
||||
$this->server->getLogger()->logException($e);
|
||||
|
||||
$this->server->getScheduler()->removeLocalComplex($task); //silent
|
||||
$task->removeDanglingStoredObjects(); //silent
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user