/** * Invoked when tick() is called for the first time. * * @param StrandInterface $strand The strand that is executing the coroutine. */ public function call(StrandInterface $strand) { $this->timer = $strand->kernel()->eventLoop()->addTimer($this->timeout, function () use($strand) { $this->timer = null; $strand->terminate(); }); $strand->call($this->coroutine); }
/** * Stop the coroutine kernel / event-loop. * * The React event-loop can optionally be stopped when all strands have been * terminated. * * @param StrandInterface $strand The currently executing strand. * @param boolean $stopEventLoop Indicates whether or not the React event-loop should also be stopped. */ public function stop(StrandInterface $strand, $stopEventLoop = true) { $strand->terminate(); $strand->kernel()->stop($stopEventLoop); }