mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
ServerScheduler::scheduleAsyncTask() returns the worker used (#1312)
This commit is contained in:
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
/**
|
||||
* Task scheduling related classes
|
||||
*/
|
||||
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\plugin\Plugin;
|
||||
@ -75,16 +76,16 @@ class ServerScheduler{
|
||||
*
|
||||
* @param AsyncTask $task
|
||||
*
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function scheduleAsyncTask(AsyncTask $task){
|
||||
public function scheduleAsyncTask(AsyncTask $task) : int{
|
||||
if($task->getTaskId() !== null){
|
||||
throw new \UnexpectedValueException("Attempt to schedule the same AsyncTask instance twice");
|
||||
}
|
||||
$id = $this->nextId();
|
||||
$task->setTaskId($id);
|
||||
$task->progressUpdates = new \Threaded;
|
||||
$this->asyncPool->submitTask($task);
|
||||
return $this->asyncPool->submitTask($task);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user