示例#1
0
 public function testAwaitAllPendingWillThrowAndCallCancellerOnTimeout()
 {
     $cancelled = false;
     $promise = new Promise\Promise(function () {
     }, function () use(&$cancelled) {
         $cancelled = true;
     });
     try {
         Block\awaitAll(array($promise), $this->loop, 0.001);
     } catch (TimeoutException $expected) {
         $this->assertTrue($cancelled);
     }
 }
 public function testAwaitAllInterrupted()
 {
     $promise = $this->createPromiseResolved(2, 0.02);
     $this->createTimerInterrupt(0.01);
     $this->assertEquals(array(2), Block\awaitAll(array($promise), $this->loop));
 }