protected function spawnWorkers($n)
{
if (FileSystem::$supported) {
eio_event_loop();
}
$n = (int) $n;
for ($i = 0; $i < $n; ++$i) {
$thread = new Worker();
$this->workers->push($thread);
$this->callbacks->push(function ($self) use($thread) {
// @check - is it possible to run iterate of main event loop without child termination?
$thread->start();
$pid = $thread->getPid();
if ($pid < 0) {
Daemon::$process->log('could not fork worker');
} elseif ($pid === 0) {
// worker
Daemon::log('Unexcepted execution return to outside of Thread->start()');
exit;
}
});
}
if ($n > 0) {
$this->lastMpmActionTs = microtime(true);
if (EventLoop::$instance) {
EventLoop::$instance->interrupt();
}
}
return true;
}