mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function scheduleAsyncTask(AsyncTask $task){
|
public function scheduleAsyncTask(AsyncTask $task){
|
||||||
|
if($task->getTaskId() !== null){
|
||||||
|
throw new \UnexpectedValueException("Attempt to schedule the same AsyncTask instance twice");
|
||||||
|
}
|
||||||
$id = $this->nextId();
|
$id = $this->nextId();
|
||||||
$task->setTaskId($id);
|
$task->setTaskId($id);
|
||||||
$task->progressUpdates = new \Threaded;
|
$task->progressUpdates = new \Threaded;
|
||||||
@ -91,6 +94,9 @@ class ServerScheduler{
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function scheduleAsyncTaskToWorker(AsyncTask $task, $worker){
|
public function scheduleAsyncTaskToWorker(AsyncTask $task, $worker){
|
||||||
|
if($task->getTaskId() !== null){
|
||||||
|
throw new \UnexpectedValueException("Attempt to schedule the same AsyncTask instance twice");
|
||||||
|
}
|
||||||
$id = $this->nextId();
|
$id = $this->nextId();
|
||||||
$task->setTaskId($id);
|
$task->setTaskId($id);
|
||||||
$task->progressUpdates = new \Threaded;
|
$task->progressUpdates = new \Threaded;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user