@@ 244-255 (lines=12) @@ | ||
241 | for ($i = 0; $i < $n; ++$i) { |
|
242 | $thread = new Worker; |
|
243 | $this->workers->push($thread); |
|
244 | $this->callbacks->push(function ($self) use ($thread) { |
|
245 | // @check - is it possible to run iterate of main event loop without child termination? |
|
246 | $thread->start(); |
|
247 | $pid = $thread->getPid(); |
|
248 | if ($pid < 0) { |
|
249 | Daemon::$process->log('could not fork worker'); |
|
250 | } elseif ($pid === 0) { // worker |
|
251 | Daemon::log('Unexcepted execution return to outside of Thread->start()'); |
|
252 | exit; |
|
253 | } |
|
254 | }); |
|
255 | } |
|
256 | if ($n > 0) { |
|
257 | $this->lastMpmActionTs = microtime(true); |
|
258 | if (EventLoop::$instance) { |
|
@@ 278-288 (lines=11) @@ | ||
275 | $thread = new IPC; |
|
276 | $this->ipcthreads->push($thread); |
|
277 | ||
278 | $this->callbacks->push(function ($self) use ($thread) { |
|
279 | $thread->start(); |
|
280 | $pid = $thread->getPid(); |
|
281 | if ($pid < 0) { |
|
282 | Daemon::$process->log('could not fork IPCThread'); |
|
283 | } elseif ($pid === 0) { // worker |
|
284 | $this->log('Unexcepted execution return to outside of Thread->start()'); |
|
285 | exit; |
|
286 | } |
|
287 | }); |
|
288 | if (EventLoop::$instance) { |
|
289 | EventLoop::$instance->interrupt(); |
|
290 | } |
|
291 | return true; |