Pool::collect PHP Method

collect() public method

Allows the Pool to collect references determined to be garbage by the given collector
public collect ( callable $collector )
$collector callable
    public function collect(callable $collector)
    {
    }

Usage Example

 /**
  * @param int $currentTick
  */
 public function mainThreadHeartbeat($currentTick)
 {
     $this->currentTick = $currentTick;
     while ($this->isReady($this->currentTick)) {
         /** @var TaskHandler $task */
         $task = $this->queue->extract();
         if ($task->isCancelled()) {
             unset($this->tasks[$task->getTaskId()]);
             continue;
         } else {
             $task->timings->startTiming();
             $task->run($this->currentTick);
             $task->timings->stopTiming();
         }
         if ($task->isRepeating()) {
             $task->setNextRun($this->currentTick + $task->getPeriod());
             $this->queue->insert($task, $this->currentTick + $task->getPeriod());
         } else {
             $task->remove();
             unset($this->tasks[$task->getTaskId()]);
         }
     }
     if ($this->asyncTasks > 0) {
         //Garbage collector
         $this->asyncPool->collect([$this, "collectAsyncTask"]);
         foreach ($this->asyncTaskStorage as $asyncTask) {
             if ($asyncTask->isFinished() and !$asyncTask->isCompleted()) {
                 $this->collectAsyncTask($asyncTask);
             }
         }
     }
 }
All Usage Examples Of Pool::collect