1 | <?php |
||
12 | abstract class AbstractPool |
||
13 | { |
||
14 | /** |
||
15 | * process list |
||
16 | * |
||
17 | * @var Process[] |
||
18 | */ |
||
19 | protected $processes = array(); |
||
20 | |||
21 | /** |
||
22 | * get process by pid |
||
23 | * |
||
24 | * @param $pid |
||
25 | * @return null|Process |
||
26 | */ |
||
27 | 3 | public function getProcessByPid($pid) |
|
37 | |||
38 | /** |
||
39 | * shutdown all process |
||
40 | * |
||
41 | * @param int $signal |
||
42 | */ |
||
43 | 9 | public function shutdown($signal = SIGTERM) |
|
51 | |||
52 | /** |
||
53 | * shutdown sub process and no wait. it is dangerous, |
||
54 | * maybe the sub process is working. |
||
55 | */ |
||
56 | 3 | public function shutdownForce() |
|
60 | |||
61 | /** |
||
62 | * get the count of running processes |
||
63 | * |
||
64 | * @return int |
||
65 | */ |
||
66 | 21 | public function aliveCount() |
|
77 | |||
78 | /** |
||
79 | * if all processes are stopped |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | 3 | public function isFinished() |
|
92 | |||
93 | /** |
||
94 | * waiting for the sub processes to exit |
||
95 | * |
||
96 | * @param bool|true $block if true the parent process will be blocked until all |
||
97 | * sub processes exit. else it will check if thers are processes that had been exited once and return. |
||
98 | * @param int $sleep when $block is true, it will check sub processes every $sleep minute |
||
99 | */ |
||
100 | 9 | public function wait($block = true, $sleep = 100) |
|
111 | } |