1010
1111class Blocker
1212{
13- private $ loop ;
14-
15- public function __construct (LoopInterface $ loop )
16- {
17- $ this ->loop = $ loop ;
18- }
19-
2013 /**
2114 * wait/sleep for $time seconds
2215 *
2316 * @param float $time
17+ * @param LoopInterface $loop
2418 */
25- public function sleep ($ time )
19+ public function sleep ($ time, LoopInterface $ loop )
2620 {
2721 $ wait = true ;
28- $ loop = $ this ->loop ;
2922 $ loop ->addTimer ($ time , function () use ($ loop , &$ wait ) {
3023 $ loop ->stop ();
3124 $ wait = false ;
@@ -40,15 +33,15 @@ public function sleep($time)
4033 * block waiting for the given $promise to resolve
4134 *
4235 * @param PromiseInterface $promise
36+ * @param LoopInterface $loop
4337 * @return mixed returns whatever the promise resolves to
4438 * @throws Exception when the promise is rejected
4539 */
46- public function await (PromiseInterface $ promise )
40+ public function await (PromiseInterface $ promise, LoopInterface $ loop )
4741 {
4842 $ wait = true ;
4943 $ resolved = null ;
5044 $ exception = null ;
51- $ loop = $ this ->loop ;
5245
5346 $ promise ->then (
5447 function ($ c ) use (&$ resolved , &$ wait , $ loop ) {
@@ -82,16 +75,16 @@ function ($error) use (&$exception, &$wait, $loop) {
8275 *
8376 * If ALL promises fail to resolve, this will fail and throw an Exception.
8477 *
85- * @param array $promises
78+ * @param array $promises
79+ * @param LoopInterface $loop
8680 * @return mixed returns whatever the first promise resolves to
8781 * @throws Exception if ALL promises are rejected
8882 */
89- public function awaitAny (array $ promises )
83+ public function awaitAny (array $ promises, LoopInterface $ loop )
9084 {
9185 $ wait = count ($ promises );
9286 $ value = null ;
9387 $ success = false ;
94- $ loop = $ this ->loop ;
9588
9689 foreach ($ promises as $ key => $ promise ) {
9790 /* @var $promise PromiseInterface */
@@ -149,16 +142,16 @@ function ($e) use (&$wait, $loop) {
149142 * If ANY promise fails to resolve, this will try to cancel() all
150143 * remaining promises and throw an Exception.
151144 *
152- * @param array $promises
145+ * @param array $promises
146+ * @param LoopInterface $loop
153147 * @return array returns an array with whatever each promise resolves to
154148 * @throws Exception when ANY promise is rejected
155149 */
156- public function awaitAll (array $ promises )
150+ public function awaitAll (array $ promises, LoopInterface $ loop )
157151 {
158152 $ wait = count ($ promises );
159153 $ exception = null ;
160154 $ values = array ();
161- $ loop = $ this ->loop ;
162155
163156 foreach ($ promises as $ key => $ promise ) {
164157 /* @var $promise PromiseInterface */
0 commit comments