Examines the value yielded from the generator and prepares the next step in interation.

@param mixed $yielded
1871
private function next($yielded)
    {
        if (!$this->generator->valid()) {
            $result = $this->generator->getReturn();

            if ($result instanceof Awaitable) {
                $this->reject(new AwaitableReturnedError($result));
                return;
            }

            if ($result instanceof Generator) {
                $this->reject(new GeneratorReturnedError($result));
                return;
            }

            $this->resolve($result);
            return;
        }

        $this->busy = true;

        if ($yielded instanceof Generator) {
            $yielded = new self($yielded);
        }

        $this->current = $yielded;

        if ($yielded instanceof Awaitable) {
            $yielded->done($this->send, $this->capture);
        } else {
            Loop\queue($this->send, $yielded);
        }

        $this->busy = false;
    }
838002
private function visitCollections(Block $block, VisitorInterface $subVisitor): Generator
    {
        foreach ($block->getCollections() as $identifier => $collection) {
            yield $identifier => $subVisitor->visit($collection);
        }
    }
1054713
public function serializeGenerator()
    {
        if($this->__converter instanceof IListConverter)
        {
            foreach($this->__converter->toGenerator($this) as $index => $row)
            {
                yield $index => $row;
            }
        }
        else
        {
            foreach($this->toArray() as $index => $row)
            {
                yield $index => $row;
            }
        }
    }
492064
public static function getApplier($yielded, array $yieldables, callable $next = null)
    {
        return function (array $results) use ($yielded, $yieldables, $next) {
            foreach ($results as $hash => $resolved) {
                $current = &$yielded;
                foreach ($yieldables[$hash]['keylist'] as $key) {
                    $current = &$current[$key];
                }
                $current = $resolved;
                unset($current);
            }
            return $next ? $next($yielded) : $yielded;
        };
    }
496626
private function buildVersionedValues(iterable $values, int $version): Generator
    {
        foreach ($values as $key => $value) {
            yield $key => new VersionedValue($value, $version);
        }
    }
1325109
protected function availableReflections(): \Generator
    {
        /**
         * @var SplFileInfo
         */
        foreach ($this->finder->getIterator() as $file) {
            $reflection = new ReflectionFile((string)$file);

            if ($reflection->hasIncludes()) {
                //We are not analyzing files which has includes, it's not safe to require such reflections
                $this->getLogger()->warning(
                    sprintf("File `%s` has includes and excluded from analysis", $file),
                    compact('file')
                );

                continue;
            }

            /*
             * @var ReflectionFile $reflection
             */
            yield $reflection;
        }
    }
192372
public function yieldify()
    {
        foreach ($this->storage as $key => $value) {
            yield (object) [
                'value' => $value,
                'key' => $key,
                'done' => false
            ];
        }

        yield (object) [
            'value' => null,
            'key' => null,
            'done' => true
        ];
    }
742985
function() {
            // run iterator for this item
            iterator(arr[current], function(err) {
                // check for any errors with this element
                if (err) {
                    callback(err, yielded);
                } else {
                    // move onto the next element
                    current++;

                    if (current === arr.length) {
                        // all done
                        callback(null, yielded);
                    } else {
                        var now = +(new Date());

                        // check if we need to take a break at all
                        if (now > endTime) {
                            // reset start and end time
                            startTime = now;
                            endTime = startTime + workTime;

                            yielded = true;

                            // prioritize setImmediate
                            if (immediate) {
                                immediate(function() {
                                    iterate();
                                });
                            } else {
                                // if we're not doing an immediate yield, also add yield time
                                endTime += yieldTime;

                                setTimeout(function() {
                                    iterate();
                                }, yieldTime);
                            }
                        } else {
                            // work on the next item immediately
                            iterate();
                        }
                    }
                }
            });
        }
861172
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('UserRefList');
        $visitor->setHeader('Content-Type', $generator->getMediaType('UserRefList'));
        //@todo Needs refactoring, disabling certain headers should not be done this way
        $visitor->setHeader('Accept-Patch', false);

        $generator->startAttribute('href', $data->path);
        $generator->endAttribute('href');

        $generator->startList('User');
        foreach ($data->users as $user) {
            $generator->startObjectElement('User');

            $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadUser', array('userId' => $user->contentInfo->id)));
            $generator->endAttribute('href');

            $generator->endObjectElement('User');
        }
        $generator->endList('User');

        $generator->endObjectElement('UserRefList');
    }
82943
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        parent::visit($visitor, $generator, $data);

        $visitorResponse = $visitor->getResponse();
        $visitorResponse->headers->add($data->response->headers->all());
        foreach ($data->response->headers->getCookies() as $cookie) {
            $visitorResponse->headers->setCookie($cookie);
        }
    }
146597
public function generate(&$result,GeneratorInterface $generator)
    {
        if($this->count() === 0) {
            throw new GeneratorException('No child scopes to call must be atleast 1');
        }
        
        $repeat_x = $this->calculateRepeatQuota($generator);
        
        # rewind the current item 
        $this->rewind();
        while($repeat_x > 0) {
            
            if($this->usingAlternatingStrategy()) {
                $randomIndex = \round($generator->generate(1,($this->count())));                
                $this->get($randomIndex)->generate($result,$generator);    
                                
            } else {
                
                foreach($this as $current) {
                    $current->generate($result,$generator);    
                }    
                
            }
            
            $repeat_x = $repeat_x -1;
        }
        
        
        return $result;
    }
4532
private function visitPlaceholders(Block $block, VisitorInterface $subVisitor): Generator
    {
        foreach ($block->getPlaceholders() as $placeholder) {
            yield $placeholder->getIdentifier() => $subVisitor->visit($placeholder);
        }
    }
810353
public function processYield(Session $session, YieldMessage $msg)
    {

        $keepIndex = true;
        $details   = new \stdClass();

        $yieldOptions = $msg->getOptions();
        if (is_object($yieldOptions) && isset($yieldOptions->progress) && $yieldOptions->progress) {
            if ($this->isProgressive()) {
                $details->progress = true;
            } else {
                // not sure what to do here - just going to drop progress
                // if we are getting progress messages that the caller didn't ask for
                return $keepIndex;
            }
        } else {
            $this->getRegistration()->removeCall($this);
            $keepIndex = false;
        }

        $resultMessage = new ResultMessage(
            $this->getCallMessage()->getRequestId(),
            $details,
            $msg->getArguments(),
            $msg->getArgumentsKw()
        );

        $this->getCallerSession()->sendMessage($resultMessage);

        return $keepIndex;
    }
1309376
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('UrlAliasList');
        $visitor->setHeader('Content-Type', $generator->getMediaType('UrlAliasList'));

        $generator->startAttribute('href', $data->path);
        $generator->endAttribute('href');

        $generator->startList('UrlAlias');
        foreach ($data->urlAliases as $urlAlias) {
            $visitor->visitValueObject($urlAlias);
        }
        $generator->endList('UrlAlias');

        $generator->endObjectElement('UrlAliasList');
    }
393678
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);
        });
    }
546963
final public function send($value)
    {
        $this->_lastValueSentIn        = $value;
        $this->_sendInvokedAtLeastOnce = true;

        /*
         * If we've already ran to the first yield statement (from rewind() or key(), for instance), we need
         * to try to move to the next position;
         */
        if ($this->_positionsExecutedCount > 0) {

            $this->_position++;
        }

        return $this->current();
    }
96459
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $status = $data->created ? 201 : 200;
        $visitor->setStatus($status);

        $visitor->setHeader('Content-Type', $generator->getMediaType('Session'));
        //@todo Needs refactoring, disabling certain headers should not be done this way
        $visitor->setHeader('Accept-Patch', false);

        $generator->startObjectElement('Session');
        $this->visitUserSessionAttributes($visitor, $generator, $data);
        $generator->endObjectElement('Session');
    }