File tree 3 files changed +58
-1
lines changed
3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 19
19
"php" : " >=8.1" ,
20
20
"hyperf/context" : " ~3.1.0" ,
21
21
"hyperf/contract" : " ~3.1.0" ,
22
- "hyperf/engine" : " ^2.13 .0"
22
+ "hyperf/engine" : " ^2.14 .0"
23
23
},
24
24
"autoload" : {
25
25
"psr-4" : {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+ /**
5
+ * This file is part of Hyperf.
6
+ *
7
+ * @link https://www.hyperf.io
8
+ * @document https://hyperf.wiki
9
+ * @contact group@hyperf.io
10
+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11
+ */
12
+
13
+ namespace Hyperf \Coroutine ;
14
+
15
+ class Barrier extends \Hyperf \Engine \Barrier
16
+ {
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+ /**
5
+ * This file is part of Hyperf.
6
+ *
7
+ * @link https://www.hyperf.io
8
+ * @document https://hyperf.wiki
9
+ * @contact group@hyperf.io
10
+ * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11
+ */
12
+
13
+ namespace HyperfTest \Coroutine ;
14
+
15
+ use Hyperf \Coroutine \Barrier ;
16
+ use Hyperf \Coroutine \Coroutine ;
17
+ use PHPUnit \Framework \TestCase ;
18
+
19
+ /**
20
+ * @internal
21
+ * @coversNothing
22
+ */
23
+ class BarrierTest extends TestCase
24
+ {
25
+ public function testBarrier ()
26
+ {
27
+ $ barrier = Barrier::create ();
28
+ $ N = 10 ;
29
+ $ count = 0 ;
30
+ for ($ i = 0 ; $ i < $ N ; ++$ i ) {
31
+ Coroutine::create (function () use (&$ count , $ barrier ) {
32
+ isset ($ barrier );
33
+ sleep (1 );
34
+ ++$ count ;
35
+ });
36
+ }
37
+ Barrier::wait ($ barrier );
38
+ $ this ->assertSame ($ N , $ count );
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments