diff --git a/README.md b/README.md index 902e118..5193363 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ function blockingExample() $request2 = $browser->get('http://www.google.co.uk/'); // keep the loop running (i.e. block) until the first response arrives - $fasterResponse = $blocker->awaitRace(array($request1, $request2)); + $fasterResponse = $blocker->awaitAny(array($request1, $request2)); return $fasterResponse->getBody(); } @@ -73,9 +73,9 @@ The `wait($seconds)` method can be used to wait/sleep for $time seconds. The `awaitOne(PromiseInterface $promise)` method can be used to block waiting for the given $promise to resolve. -#### awaitRace() +#### awaitAny() -The `awaitRace(array $promises)` method can be used to wait for ANY of the given promises to resolve. +The `awaitAny(array $promises)` method can be used to wait for ANY of the given promises to resolve. #### awaitAll() diff --git a/src/Blocker.php b/src/Blocker.php index 63f3761..579acdd 100644 --- a/src/Blocker.php +++ b/src/Blocker.php @@ -86,7 +86,7 @@ function ($error) use (&$exception, &$wait, $loop) { * @return mixed returns whatever the first promise resolves to * @throws Exception if ALL promises are rejected */ - public function awaitRace(array $promises) + public function awaitAny(array $promises) { $wait = count($promises); $value = null; diff --git a/tests/BlockerTest.php b/tests/BlockerTest.php index e0629e6..30b6166 100644 --- a/tests/BlockerTest.php +++ b/tests/BlockerTest.php @@ -49,12 +49,12 @@ public function testAwaitOneInterrupted() /** * @expectedException UnderflowException */ - public function testAwaitRaceEmpty() + public function testAwaitAnyEmpty() { - $this->block->awaitRace(array()); + $this->block->awaitAny(array()); } - public function testAwaitRaceFirstResolved() + public function testAwaitAnyFirstResolved() { $all = array( $this->createPromiseRejected(1), @@ -62,10 +62,10 @@ public function testAwaitRaceFirstResolved() $this->createPromiseResolved(3, 0.02) ); - $this->assertEquals(2, $this->block->awaitRace($all)); + $this->assertEquals(2, $this->block->awaitAny($all)); } - public function testAwaitRaceFirstResolvedConcurrently() + public function testAwaitAnyFirstResolvedConcurrently() { $d1 = new Deferred(); $d2 = new Deferred(); @@ -83,10 +83,10 @@ public function testAwaitRaceFirstResolvedConcurrently() $d3->promise() ); - $this->assertEquals(2, $this->block->awaitRace($all)); + $this->assertEquals(2, $this->block->awaitAny($all)); } - public function testAwaitRaceAllRejected() + public function testAwaitAnyAllRejected() { $all = array( $this->createPromiseRejected(1), @@ -94,15 +94,15 @@ public function testAwaitRaceAllRejected() ); $this->setExpectedException('UnderflowException'); - $this->block->awaitRace($all); + $this->block->awaitAny($all); } - public function testAwaitRaceInterrupted() + public function testAwaitAnyInterrupted() { $promise = $this->createPromiseResolved(2, 0.02); $this->createTimerInterrupt(0.01); - $this->assertEquals(2, $this->block->awaitRace(array($promise))); + $this->assertEquals(2, $this->block->awaitAny(array($promise))); } public function testAwaitAllEmpty()