Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * 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);
 }