Example #1
0
 /**
  * Birth by child process
  *
  * @param Process $child
  */
 public function init(Process $child)
 {
     $that = $this;
     $child->on('message', function ($message) use($that) {
         $that->emit('message', $message);
         $that->cluster->emit('message', $that, $message);
     });
     $child->on('finish', function ($code) use($that) {
         $that->finish($code);
     });
     $child->on('exit', function ($code) use($that) {
         $that->shutdown($code);
     });
     $child->on('fork', function () use($that) {
         $that->fork();
     });
     $this->child = $child;
 }
Example #2
0
 protected function createProcess(callable $callable)
 {
     $p = new Process($callable);
     $p->setSharedMemory(new SharedMemory());
     $p->on('exit', function ($pid) use($p) {
         $this->childProcessDie($pid, $p->getStatus());
     });
     return $p;
 }