@@ -8,10 +8,10 @@ |
||
8 | 8 | |
9 | 9 | $begin = microtime(true); |
10 | 10 | |
11 | -for ($r = 0; $r < 102400; $r ++) { |
|
12 | - new Job((function () { |
|
11 | +for ($r = 0; $r < 102400; $r++) { |
|
12 | + new Job((function() { |
|
13 | 13 | yield 111; |
14 | - yield (function () { |
|
14 | + yield (function() { |
|
15 | 15 | yield 'hello'; |
16 | 16 | return 'world'; |
17 | 17 | })(); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $this->chain = new SplStack; |
105 | 105 | |
106 | - ($this->ender = Promise::deferred())->catch(function (...$args) { |
|
106 | + ($this->ender = Promise::deferred())->catch(function(...$args) { |
|
107 | 107 | $this->killed(...$args); |
108 | 108 | }); |
109 | 109 | |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | { |
225 | 225 | $this->sleep = $await; |
226 | 226 | |
227 | - $await->then(function ($r = null) { |
|
227 | + $await->then(function($r = null) { |
|
228 | 228 | $this->wakeup($r); |
229 | - }, function (Throwable $e = null) { |
|
229 | + }, function(Throwable $e = null) { |
|
230 | 230 | $this->wakeup($e ?? new RejectedException); |
231 | 231 | }); |
232 | 232 |
@@ -20,6 +20,6 @@ |
||
20 | 20 | */ |
21 | 21 | public static function next() : int |
22 | 22 | { |
23 | - return self::$current ++ >= PHP_INT_MAX ? self::$current = 1 : self::$current; |
|
23 | + return self::$current++ >= PHP_INT_MAX ? self::$current = 1 : self::$current; |
|
24 | 24 | } |
25 | 25 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | public static function promises(array $programs, Context $ctx = null) : array |
45 | 45 | { |
46 | - return array_map(static function ($program) use ($ctx) { |
|
46 | + return array_map(static function($program) use ($ctx) { |
|
47 | 47 | return self::promised($program, [], $ctx); |
48 | 48 | }, $programs); |
49 | 49 | } |
@@ -27,13 +27,13 @@ |
||
27 | 27 | */ |
28 | 28 | public static function created() : void |
29 | 29 | { |
30 | - self::$running ++; |
|
30 | + self::$running++; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | */ |
35 | 35 | public static function finished() : void |
36 | 36 | { |
37 | - self::$running --; |
|
37 | + self::$running--; |
|
38 | 38 | } |
39 | 39 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | ) : Promised { |
30 | 30 | $racer = Promise::deferred(); |
31 | 31 | if ($ms > 0) { |
32 | - $timer = Timer::after($ms, static function () use ($racer, $ec, $em) { |
|
32 | + $timer = Timer::after($ms, static function() use ($racer, $ec, $em) { |
|
33 | 33 | $racer->throw(new $ec($em)); |
34 | 34 | }); |
35 | - $racer->catch(static function () use ($timer) { |
|
35 | + $racer->catch(static function() use ($timer) { |
|
36 | 36 | Timer::clear($timer); |
37 | 37 | }); |
38 | 38 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | int $ms, |
50 | 50 | Closure $do = null |
51 | 51 | ) : Promised { |
52 | - return new Promise(static function (Promised $promised) use ($ms, $do) { |
|
53 | - $tick = Timer::after($ms, static function () use ($promised, $do) { |
|
52 | + return new Promise(static function(Promised $promised) use ($ms, $do) { |
|
53 | + $tick = Timer::after($ms, static function() use ($promised, $do) { |
|
54 | 54 | $promised->resolve($do ? $do() : null); |
55 | 55 | }); |
56 | - $promised->catch(static function () use ($tick) { |
|
56 | + $promised->catch(static function() use ($tick) { |
|
57 | 57 | Timer::clear($tick); |
58 | 58 | }); |
59 | 59 | }); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function co($program, Context $ctx = null) : Closure |
79 | 79 | { |
80 | - return static function (...$args) use ($program, $ctx) { |
|
80 | + return static function(...$args) use ($program, $ctx) { |
|
81 | 81 | return async($program, $ctx, ...$args)->fusion(); |
82 | 82 | }; |
83 | 83 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | string $message = '' |
112 | 112 | ) : Promised { |
113 | 113 | return race( |
114 | - new Promise(static function (Promised $await) use ($dial, $awake) { |
|
115 | - $dial(static function (...$args) use ($await, $awake) { |
|
114 | + new Promise(static function(Promised $await) use ($dial, $awake) { |
|
115 | + $dial(static function(...$args) use ($await, $awake) { |
|
116 | 116 | try { |
117 | 117 | $await->pended() && $out = $awake(...$args); |
118 | 118 | $await->pended() && $await->resolve($out ?? null); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | function ctx() : Syscall |
132 | 132 | { |
133 | - return new Syscall(static function (Job $job) { |
|
133 | + return new Syscall(static function(Job $job) { |
|
134 | 134 | return $job->ctx(); |
135 | 135 | }); |
136 | 136 | } |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function defer(Closure $program) : Syscall |
143 | 143 | { |
144 | - return new Syscall(static function (Job $job) use ($program) { |
|
145 | - $job->roll()->then(static function ($stage) use ($job, $program) { |
|
144 | + return new Syscall(static function(Job $job) use ($program) { |
|
145 | + $job->roll()->then(static function($stage) use ($job, $program) { |
|
146 | 146 | co($program, $job->ctx())($stage); |
147 | 147 | }); |
148 | 148 | }); |