File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 1919 "php" : " >=8.2" ,
2020 "hyperf/context" : " ~3.2.0" ,
2121 "hyperf/contract" : " ~3.2.0" ,
22- "hyperf/engine" : " ^2.13 .0"
22+ "hyperf/engine" : " ^2.14 .0"
2323 },
2424 "autoload" : {
2525 "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+ 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+ 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