src/Co.php
private function processGeneratorContainerRunning(GeneratorContainer $gc)
    {
        // Check delay request yields
        if ($gc->key() === CoInterface::DELAY) {
            return $this->pool->addDelay($gc->current())
            ->then(function () use ($gc) {
                $gc->send(null);
                return $this->processGeneratorContainer($gc);
            });
        }

        // Now we normalize yielded value
        $yielded = YieldableUtils::normalize($gc->current());
        $yieldables = YieldableUtils::getYieldables($yielded, [], $this->runners);
        if (!$yieldables) {
            // If there are no yieldables, send yielded value back into generator
            $gc->send($yielded);
            // Continue
            return $this->processGeneratorContainer($gc);
        }

        // Chain resolver
        return $this->promiseAll($yieldables, $gc->key() !== CoInterface::SAFE)
        ->then(
            YieldableUtils::getApplier($yielded, $yieldables, [$gc, 'send']),
            [$gc, 'throw_']
        )->then(function () use ($gc, $yieldables) {
            // Continue
            $this->runners = array_diff_key($this->runners, $yieldables);
            return $this->processGeneratorContainer($gc);
        });
    }
private function processGeneratorContainerRunning(GeneratorContainer $gc)
    {
        // Check delay request yields
        if ($gc->key() === CoInterface::DELAY) {
            return $this->pool->addDelay($gc->current())
            ->then(function () use ($gc) {
                $gc->send(null);
                return $this->processGeneratorContainer($gc);
            });
        }

        // Now we normalize yielded value
        $yielded = YieldableUtils::normalize($gc->current());
        $yieldables = YieldableUtils::getYieldables($yielded, [], $this->runners);
        if (!$yieldables) {
            // If there are no yieldables, send yielded value back into generator
            $gc->send($yielded);
            // Continue
            return $this->processGeneratorContainer($gc);
        }

        // Chain resolver
        return $this->promiseAll($yieldables, $gc->key() !== CoInterface::SAFE)
        ->then(
            YieldableUtils::getApplier($yielded, $yieldables, [$gc, 'send']),
            [$gc, 'throw_']
        )->then(function () use ($gc, $yieldables) {
            // Continue
            $this->runners = array_diff_key($this->runners, $yieldables);
            return $this->processGeneratorContainer($gc);
        });
    }
private function processGeneratorContainerRunning ( GeneratorContainer $ gc ) { // Check delay request yields if ( $ gc -> key ( ) === CoInterface :: DELAY ) { return $ this -> pool -> addDelay ( $ gc -> current ( ) ) -> then ( function ( ) use ( $ gc ) { $ gc -> send ( null ) ; return $ this -> processGeneratorContainer ( $ gc ) ; } ) ; } // Now we normalize yielded value $ yielded = YieldableUtils :: normalize ( $ gc -> current ( ) ) ; $ yieldables = YieldableUtils :: getYieldables ( $ yielded , [ ] , $ this -> runners ) ; if ( ! $ yieldables ) { // If there are no yieldables, send yielded value back into generator $ gc -> send ( $ yielded ) ; // Continue return $ this -> processGeneratorContainer ( $ gc ) ; } // Chain resolver return $ this -> promiseAll ( $ yieldables , $ gc -> key ( ) !== CoInterface :: SAFE ) -> then ( YieldableUtils :: getApplier ( $ yielded , $ yieldables , [ $ gc , 'send' ] ) , [ $ gc , 'throw_' ] ) -> then ( function ( ) use ( $ gc , $ yieldables ) { // Continue $ this -> runners = array_diff_key ( $ this -> runners , $ yieldables ) ; return $ this -> processGeneratorContainer ( $ gc ) ; } ) ; }
Handle resolving generators still running.
@param  GeneratorContainer $gc
@return PromiseInterface
Handle resolving generators still running .