get() public static méthode

Retrieve the event loop driver that is in scope.
public static get ( ) : Driver
Résultat Interop\Async\Loop\Driver
 /** @test */
 public function executeStackReturnsScopedDriver()
 {
     $driver1 = new DummyDriver();
     $driver2 = new DummyDriver();
     Loop::execute(function () use($driver1, $driver2) {
         $this->assertSame($driver1, Loop::get());
         Loop::execute(function () use($driver2) {
             $this->assertSame($driver2, Loop::get());
         }, $driver2);
         $this->assertSame($driver1, Loop::get());
     }, $driver1);
 }
Exemple #2
0
 /**
  * Check if a loop implementation is available
  *
  * @return bool
  */
 protected function hasActiveLoop()
 {
     try {
         Loop::get();
         return true;
     } catch (\LogicException $exception) {
         return false;
     }
 }