示例#1
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();
 }
示例#2
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);
 }