mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Disallow scheduling the same AsyncTask instance more than once
This commit is contained in:
parent
f0f6d85809
commit
da23568546
@ -76,6 +76,9 @@ class ServerScheduler{
|
||||
* @return void
|
||||
*/
|
||||
public function scheduleAsyncTask(AsyncTask $task){
|
||||
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;
|
||||
@ -91,6 +94,9 @@ class ServerScheduler{
|
||||
* @return void
|
||||
*/
|
||||
public function scheduleAsyncTaskToWorker(AsyncTask $task, $worker){
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user