Skip to content

Commit 5af4f27

Browse files
committed
Merge pull request #9 from clue-labs/any
Rename awaitRace() to awaitAny()
2 parents 87fbae6 + fb18d00 commit 5af4f27

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function blockingExample()
4646
$request2 = $browser->get('http://www.google.co.uk/');
4747

4848
// keep the loop running (i.e. block) until the first response arrives
49-
$fasterResponse = $blocker->awaitRace(array($request1, $request2));
49+
$fasterResponse = $blocker->awaitAny(array($request1, $request2));
5050

5151
return $fasterResponse->getBody();
5252
}
@@ -73,9 +73,9 @@ The `sleep($seconds)` method can be used to wait/sleep for $time seconds.
7373

7474
The `awaitOne(PromiseInterface $promise)` method can be used to block waiting for the given $promise to resolve.
7575

76-
#### awaitRace()
76+
#### awaitAny()
7777

78-
The `awaitRace(array $promises)` method can be used to wait for ANY of the given promises to resolve.
78+
The `awaitAny(array $promises)` method can be used to wait for ANY of the given promises to resolve.
7979

8080
#### awaitAll()
8181

src/Blocker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function ($error) use (&$exception, &$wait, $loop) {
8686
* @return mixed returns whatever the first promise resolves to
8787
* @throws Exception if ALL promises are rejected
8888
*/
89-
public function awaitRace(array $promises)
89+
public function awaitAny(array $promises)
9090
{
9191
$wait = count($promises);
9292
$value = null;

tests/BlockerTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@ public function testAwaitOneInterrupted()
4949
/**
5050
* @expectedException UnderflowException
5151
*/
52-
public function testAwaitRaceEmpty()
52+
public function testAwaitAnyEmpty()
5353
{
54-
$this->block->awaitRace(array());
54+
$this->block->awaitAny(array());
5555
}
5656

57-
public function testAwaitRaceFirstResolved()
57+
public function testAwaitAnyFirstResolved()
5858
{
5959
$all = array(
6060
$this->createPromiseRejected(1),
6161
$this->createPromiseResolved(2, 0.01),
6262
$this->createPromiseResolved(3, 0.02)
6363
);
6464

65-
$this->assertEquals(2, $this->block->awaitRace($all));
65+
$this->assertEquals(2, $this->block->awaitAny($all));
6666
}
6767

68-
public function testAwaitRaceFirstResolvedConcurrently()
68+
public function testAwaitAnyFirstResolvedConcurrently()
6969
{
7070
$d1 = new Deferred();
7171
$d2 = new Deferred();
@@ -83,26 +83,26 @@ public function testAwaitRaceFirstResolvedConcurrently()
8383
$d3->promise()
8484
);
8585

86-
$this->assertEquals(2, $this->block->awaitRace($all));
86+
$this->assertEquals(2, $this->block->awaitAny($all));
8787
}
8888

89-
public function testAwaitRaceAllRejected()
89+
public function testAwaitAnyAllRejected()
9090
{
9191
$all = array(
9292
$this->createPromiseRejected(1),
9393
$this->createPromiseRejected(2)
9494
);
9595

9696
$this->setExpectedException('UnderflowException');
97-
$this->block->awaitRace($all);
97+
$this->block->awaitAny($all);
9898
}
9999

100-
public function testAwaitRaceInterrupted()
100+
public function testAwaitAnyInterrupted()
101101
{
102102
$promise = $this->createPromiseResolved(2, 0.02);
103103
$this->createTimerInterrupt(0.01);
104104

105-
$this->assertEquals(2, $this->block->awaitRace(array($promise)));
105+
$this->assertEquals(2, $this->block->awaitAny(array($promise)));
106106
}
107107

108108
public function testAwaitAllEmpty()

0 commit comments

Comments
 (0)