stop() public method

Instruct a running event loop to stop.
public stop ( )
Example #1
0
 /**
  *
  */
 private function stop()
 {
     if ($this->loop !== null && $this->loop->isRunning()) {
         $this->loop->stop();
     }
     if ($this->stopFlags === false) {
         $callable = $this->stopCallback;
         $callable($this);
     }
     $this->stopFlags = true;
 }
Example #2
0
 /**
  * @dataProvider loopsProvider
  * @param LoopExtendedInterface|LoopModelInterface|mixed $loop
  */
 public function testApiStartAndApiStop_StartsAndStopsLoop($loop)
 {
     $loop->onAfterTick(function () use($loop) {
         $this->assertTrue($loop->isRunning());
         $loop->stop();
         $this->assertFalse($loop->isRunning());
     });
     $loop->start();
     unset($loop);
 }