Icicle\Concurrent\Worker\Internal\TaskRunner::run PHP Method

run() public method

public run ( ) : Generator
return Generator
    public function run() : \Generator
    {
        $task = (yield from $this->channel->receive());
        while ($task instanceof Task) {
            $this->idle = false;
            try {
                $result = (yield $task->run($this->environment));
            } catch (\Throwable $exception) {
                $result = new TaskFailure($exception);
            }
            yield from $this->channel->send($result);
            $this->idle = true;
            $task = (yield from $this->channel->receive());
        }
        return $task;
    }

Usage Example

Example #1
0
 public function __construct()
 {
     parent::__construct(new Thread(function () {
         $runner = new TaskRunner($this, new Environment());
         yield $runner->run();
     }));
 }
All Usage Examples Of Icicle\Concurrent\Worker\Internal\TaskRunner::run