diff --git a/src/pocketmine/scheduler/AsyncTask.php b/src/pocketmine/scheduler/AsyncTask.php index c1adfa1db..ffa7fc8ec 100644 --- a/src/pocketmine/scheduler/AsyncTask.php +++ b/src/pocketmine/scheduler/AsyncTask.php @@ -28,7 +28,7 @@ use pocketmine\Server; * * WARNING: Do not call PocketMine-MP API methods from other Threads!! */ -abstract class AsyncTask extends \Threaded{ +abstract class AsyncTask extends \Collectable{ protected $complete = null; protected $finished = null; @@ -43,6 +43,7 @@ abstract class AsyncTask extends \Threaded{ $this->onRun(); $this->finished = true; + $this->setGarbage(); } diff --git a/src/pocketmine/scheduler/ServerScheduler.php b/src/pocketmine/scheduler/ServerScheduler.php index 696ac2a7e..e832b8b74 100644 --- a/src/pocketmine/scheduler/ServerScheduler.php +++ b/src/pocketmine/scheduler/ServerScheduler.php @@ -45,9 +45,6 @@ class ServerScheduler{ protected $asyncTasks = 0; - /** @var AsyncTask[] */ - protected $asyncTaskStorage = []; - /** @var int */ private $ids = 1; @@ -80,7 +77,6 @@ class ServerScheduler{ $id = $this->nextId(); $task->setTaskId($id); $this->asyncPool->submit($task); - $this->asyncTaskStorage[$id] = $task; ++$this->asyncTasks; } @@ -245,12 +241,6 @@ class ServerScheduler{ if($this->asyncTasks > 0){ //Garbage collector $this->asyncPool->collect([$this, "collectAsyncTask"]); - - foreach($this->asyncTaskStorage as $asyncTask){ - if($asyncTask->isFinished() and !$asyncTask->isCompleted()){ - $this->collectAsyncTask($asyncTask); - } - } } } @@ -259,7 +249,6 @@ class ServerScheduler{ --$this->asyncTasks; $task->onCompletion(Server::getInstance()); $task->setCompleted(); - unset($this->asyncTaskStorage[$task->getTaskId()]); return true; } diff --git a/src/spl b/src/spl index e565959cc..1095acf14 160000 --- a/src/spl +++ b/src/spl @@ -1 +1 @@ -Subproject commit e565959cc14235329d428c25e7b1a2d1cf4874c7 +Subproject commit 1095acf146aaf8c9dffeea4d04999322fd5627d9