PHPDaemon\Thread\Collection::removeTerminated PHP Method

removeTerminated() public method

Remove terminated threads from the collection
public removeTerminated ( ) : integer
return integer Rest threads count
    public function removeTerminated()
    {
        // @TODO: remove
        $n = 0;
        foreach ($this->threads as $id => $thread) {
            if (!$thread->getPid() || !$thread->ifExists()) {
                $thread->setTerminated();
                unset($this->threads[$id]);
                continue;
            }
            ++$n;
        }
        return $n;
    }