-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
52 lines (44 loc) · 1.23 KB
/
Copy pathprocess.php
File metadata and controls
52 lines (44 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
include dirname(__DIR__) . '/src/autoload.php';
use phpth\process\Process;
use phpth\process\supply\ChildRestart;
$p = new Process();
// main process title
$p->name = 'tset';
$p->childRestart = ChildRestart::NO_RESTART;
$e = $p->runCall(function () {
echo 'CHILD RUN' . PHP_EOL;
sleep(1);
}, [], 3, 'escc');
$p->waitExecutor($e, true, 0.9, function (int $idx, array $status, $append_param1, $append_param2) {
//print_r($status);
echo 'idx: ', $idx, ' - ', $append_param1, ' - ', $append_param2, PHP_EOL;
}, ['append_param1', 'append_param2']);
$e = $p->runMultiCall([
['call' => function () {
echo 'child for ddd' . PHP_EOL;
sleep(3);
},
'name' => 'ddd'],
['call' => function () {
echo 'child for ccc' . PHP_EOL;
sleep(3);
},
'name' => 'ccc']
]);
$p->waitExecutor($e, true, 0.9, function (int $idx, array $status, $append_param1, $append_param2) {
//print_r($status);
echo 'idx: ', $idx, ' - ', $append_param1, ' - ', $append_param2, PHP_EOL;
}, ['append_param1', 'append_param2']);
/*function test():Generator
{
$i = 0;
while(true){
sleep(1);
yield $i;
$i++;
}
}
foreach(test() as $k=> $v){
echo $v, PHP_EOL;
}*/