@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | ->setInstance($worker) |
94 | 94 | ->setLooptime($looptime) |
95 | 95 | ->setForever($forever) |
96 | - ->setInputChannel(new SharedMemory((int)'1'.hexdec($worker->getId()))) |
|
97 | - ->setOutputChannel(new SharedMemory((int)'2'.hexdec($worker->getId()))); |
|
96 | + ->setInputChannel(new SharedMemory((int) '1'.hexdec($worker->getId()))) |
|
97 | + ->setOutputChannel(new SharedMemory((int) '2'.hexdec($worker->getId()))); |
|
98 | 98 | |
99 | 99 | $this->data[$name] = $w; |
100 | 100 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | $worker->getInputChannel()->close(); |
142 | 142 | $worker->getOutputChannel()->close(); |
143 | 143 | // open brand new channels |
144 | - $worker->setInputChannel(new SharedMemory((int)'1'.hexdec($worker->getInstance()->getId()))) |
|
145 | - ->setOutputChannel(new SharedMemory((int)'2'.hexdec($worker->getInstance()->getId()))); |
|
144 | + $worker->setInputChannel(new SharedMemory((int) '1'.hexdec($worker->getInstance()->getId()))) |
|
145 | + ->setOutputChannel(new SharedMemory((int) '2'.hexdec($worker->getInstance()->getId()))); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // fork worker |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | public function stop($name = null) { |
197 | 197 | |
198 | - foreach ($this->data as $wname => $worker) { |
|
198 | + foreach ( $this->data as $wname => $worker ) { |
|
199 | 199 | |
200 | 200 | $wpid = $worker->getPid(); |
201 | 201 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | // try to gently ask the worker to close |
208 | 208 | $worker->getOutputChannel()->send('stop'); |
209 | 209 | |
210 | - while (time() < $time) { |
|
210 | + while ( time() < $time ) { |
|
211 | 211 | |
212 | 212 | if ( !$this->running($wpid) ) break; |
213 | 213 | usleep(20000); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $worker->getOutputChannel()->close(); |
220 | 220 | |
221 | 221 | // terminate the worker if still alive |
222 | - if ($this->running($wpid)) ProcessTools::term($wpid, 5, SIGTERM); |
|
222 | + if ( $this->running($wpid) ) ProcessTools::term($wpid, 5, SIGTERM); |
|
223 | 223 | |
224 | 224 | } |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | if ( empty($name) ) { |
233 | 233 | $result = []; |
234 | - foreach ($this->data as $name => $worker) { |
|
234 | + foreach ( $this->data as $name => $worker ) { |
|
235 | 235 | $result[$name] = $worker->getOutputChannel()->send('pause') > 0; |
236 | 236 | } |
237 | 237 | return $result; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | if ( empty($name) ) { |
247 | 247 | $result = []; |
248 | - foreach ($this->data as $name => $worker) { |
|
248 | + foreach ( $this->data as $name => $worker ) { |
|
249 | 249 | $result[$name] = $worker->getOutputChannel()->send('resume') > 0; |
250 | 250 | } |
251 | 251 | return $result; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | if ( $name === null ) { |
267 | 267 | |
268 | 268 | $result = []; |
269 | - foreach ($this->data as $name => $worker) { |
|
269 | + foreach ( $this->data as $name => $worker ) { |
|
270 | 270 | $result[$name] = $this->getStatus($worker); |
271 | 271 | } |
272 | 272 | return $result; |