File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
tests/swoole_coroutine/output Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ swoole_coroutine/output: concurrency
3
+ --SKIPIF--
4
+ <?php require __DIR__ . '/../../include/skipif.inc ' ; ?>
5
+ --FILE--
6
+ <?php
7
+ require __DIR__ . '/../../include/bootstrap.php ' ;
8
+ ob_start ();
9
+ echo "cid 0 \n" ;
10
+
11
+ Co \run (function () {
12
+ ob_start ();
13
+ echo "cid 1 \n" ;
14
+
15
+ $ list = [];
16
+ $ n = MAX_REQUESTS ;
17
+ while ($ n --) {
18
+ $ list [] = Co \go (function () {
19
+ ob_start ();
20
+ $ cid = co::getCid ();
21
+ echo "cid {$ cid } [1] \n" ;
22
+ usleep (random_int (1000 , 5000 ));
23
+ echo "cid {$ cid } [2] \n" ;
24
+ usleep (random_int (1000 , 5000 ));
25
+ echo "cid {$ cid } [3] \n" ;
26
+ usleep (random_int (1000 , 5000 ));
27
+ Assert::eq (
28
+ ob_get_clean (),
29
+ implode ('' , [
30
+ "cid {$ cid } [1] \n" ,
31
+ "cid {$ cid } [2] \n" ,
32
+ "cid {$ cid } [3] \n" ,
33
+ ])
34
+ );
35
+ });
36
+ }
37
+ co::join ($ list );
38
+
39
+ Assert::eq (ob_get_clean (), "cid 1 \n" );
40
+ });
41
+
42
+ Assert::eq (ob_get_clean (), "cid 0 \n" );
43
+ ?>
44
+ --EXPECT--
You can’t perform that action at this time.
0 commit comments