mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Added AsyncTask::onCompletion()
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
use pocketmine\Server;
|
||||
|
||||
/**
|
||||
* Class used to run async tasks in other threads.
|
||||
@ -91,4 +92,13 @@ abstract class AsyncTask extends \Threaded{
|
||||
*/
|
||||
public abstract function onRun();
|
||||
|
||||
/**
|
||||
* Actions to execute when completed (on main thread)
|
||||
*
|
||||
* @param Server $server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public abstract function onCompletion(Server $server);
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
|
||||
class ServerScheduler{
|
||||
@ -216,7 +217,7 @@ class ServerScheduler{
|
||||
$this->asyncPool->collect(function (AsyncTask $task){
|
||||
if($task->isCompleted() or ($task->isFinished() and !$task->hasResult())){
|
||||
--$this->asyncTasks;
|
||||
|
||||
$task->onCompletion(Server::getInstance());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user