1 | <?php |
||
15 | class Snidel |
||
16 | { |
||
17 | /** @var string */ |
||
18 | const VERSION = '0.6.5'; |
||
19 | |||
20 | /** @var \Ackintosh\Snidel\Fork\Container */ |
||
21 | private $container; |
||
22 | |||
23 | /** @var \Ackintosh\Snidel\Pcntl */ |
||
24 | private $pcntl; |
||
25 | |||
26 | /** @var int */ |
||
27 | private $concurrency; |
||
28 | |||
29 | /** @var \Ackintosh\Snidel\Log */ |
||
30 | private $log; |
||
31 | |||
32 | /** @var bool */ |
||
33 | private $joined = false; |
||
34 | |||
35 | /** @var int */ |
||
36 | private $ownerPid; |
||
37 | |||
38 | /** @var array */ |
||
39 | private $signals = array( |
||
40 | SIGTERM, |
||
41 | SIGINT, |
||
42 | ); |
||
43 | |||
44 | /** @var int */ |
||
45 | private $receivedSignal; |
||
46 | |||
47 | /** @var bool */ |
||
48 | private $exceptionHasOccured = false; |
||
49 | |||
50 | public function __construct($concurrency = 5) |
||
78 | |||
79 | /** |
||
80 | * sets the resource for the log. |
||
81 | * |
||
82 | * @param resource $resource |
||
83 | * @return void |
||
84 | * @codeCoverageIgnore |
||
85 | */ |
||
86 | public function setLoggingDestination($resource) |
||
90 | |||
91 | /** |
||
92 | * this method uses master / worker model. |
||
93 | * |
||
94 | * @param callable $callable |
||
95 | * @param mixed $args |
||
96 | * @param string $tag |
||
97 | * @return void |
||
98 | * @throws \RuntimeException |
||
99 | */ |
||
100 | public function fork($callable, $args = array(), $tag = null) |
||
116 | |||
117 | /** |
||
118 | * waits until all tasks that queued by Snidel::fork() are completed |
||
119 | * |
||
120 | * @return void |
||
121 | */ |
||
122 | public function wait() |
||
127 | |||
128 | /** |
||
129 | * @return bool |
||
130 | */ |
||
131 | public function hasError() |
||
135 | |||
136 | /** |
||
137 | * @return \Ackintosh\Snidel\Error |
||
138 | */ |
||
139 | public function getError() |
||
143 | |||
144 | /** |
||
145 | * gets results |
||
146 | * |
||
147 | * @param string $tag |
||
148 | * @return \Ackintosh\Snidel\Result\Collection |
||
149 | * @throws \InvalidArgumentException |
||
150 | */ |
||
151 | public function get($tag = null) |
||
162 | |||
163 | public function setReceivedSignal($sig) |
||
167 | /** |
||
168 | * delete shared memory |
||
169 | * |
||
170 | * @return void |
||
171 | * @throws \Ackintosh\Snidel\Exception\SharedMemoryControlException |
||
172 | */ |
||
173 | private function deleteAllData() |
||
182 | |||
183 | public function __destruct() |
||
210 | } |
||
211 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.