private function removeTask(AsyncTask $task, $force = false) { if (isset($this->taskWorkers[$task->getTaskId()])) { if (!$force and ($task->isRunning() or !$task->isGarbage())) { return; } $this->workerUsage[$this->taskWorkers[$task->getTaskId()]]--; } unset($this->tasks[$task->getTaskId()]); unset($this->taskWorkers[$task->getTaskId()]); $task->cleanObject(); }
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()]); }
/** * 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); }
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; }
private function removeTask(AsyncTask $task, $force = false) { unset($this->tasks[$task->getTaskId()]); }