Disallow scheduling the same AsyncTask instance more than once

This commit is contained in:
SOFe 2016-11-11 22:53:20 +08:00
parent f0f6d85809
commit da23568546
No known key found for this signature in database
GPG Key ID: A0379676C4D9D5D9

View File

@ -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;