WARNING: Do not call PocketMine-MP API methods, or save objects from/on other Threads!!
Inheritance: extends Collectable
Exemplo n.º 1
0
 private function removeTask(AsyncTask $task)
 {
     if (isset($this->taskWorkers[$task->getTaskId()])) {
         $this->workers[$w = $this->taskWorkers[$task->getTaskId()]]->unstack($task);
         $this->workerUsage[$w]--;
     }
     unset($this->tasks[$task->getTaskId()]);
     unset($this->taskWorkers[$task->getTaskId()]);
 }
Exemplo n.º 2
0
 private function removeTask(AsyncTask $task, $force = false)
 {
     if (isset($this->taskWorkers[$task->getTaskId()])) {
         if (!$force and ($task->isRunning() or !$task->isGarbage())) {
             return;
         }
         $this->workers[$w = $this->taskWorkers[$task->getTaskId()]]->unstack($task);
         $this->workerUsage[$w]--;
     }
     unset($this->tasks[$task->getTaskId()]);
     unset($this->taskWorkers[$task->getTaskId()]);
     $task->cleanObject();
 }
Exemplo n.º 3
0
 /**
  * Submits an asynchronous task to a specific Worker in the Pool
  *
  * @param AsyncTask $task
  * @param int       $worker
  *
  * @return void
  */
 public function scheduleAsyncTaskToWorker(AsyncTask $task, $worker)
 {
     $id = $this->nextId();
     $task->setTaskId($id);
     $this->asyncPool->submitTaskToWorker($task, $worker);
 }
Exemplo n.º 4
0
 /**
  * Submits an asynchronous task to the Worker Pool
  *
  * @param AsyncTask $task
  *
  * @return void
  */
 public function scheduleAsyncTask(AsyncTask $task)
 {
     $id = $this->nextId();
     $task->setTaskId($id);
     $this->asyncPool->submitTask($task);
 }
Exemplo n.º 5
0
 public function collectAsyncTask(AsyncTask $task)
 {
     if ($task->isFinished() and !$task->isCompleted()) {
         --$this->asyncTasks;
         $task->onCompletion(Server::getInstance());
         $task->setCompleted();
         unset($this->asyncTaskStorage[$task->getTaskId()]);
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Submits an asynchronous task to a specific Worker in the Pool
  *
  * @param AsyncTask $task
  * @param int       $worker
  *
  * @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();
     $this->asyncPool->submitTaskToWorker($task, $worker);
 }
Exemplo n.º 7
0
 private function removeTask(AsyncTask $task, $force = false)
 {
     unset($this->tasks[$task->getTaskId()]);
 }