spawn() public method

public spawn ( callable $callable ) : ko\Process
$callable callable Callable with prototype like function(Ko\Process $p) }
return ko\Process
 public function testReSpawnedProcessHasPersistSharedMemorySegment()
 {
     $process = $this->manager->spawn(function (Process $p) {
         $sm = $p->getSharedMemory();
         $sm['spawnCount'] += 1;
         $exitCode = $sm['spawnCount'] == 1 ? -1 : 0;
         exit($exitCode);
     });
     $this->manager->wait();
     $this->assertEquals(2, $process->getSharedMemory()['spawnCount']);
 }
示例#2
0
 protected function runChilds()
 {
     $count = $this->getWorkerCount();
     for ($i = 0; $i < $count; $i++) {
         $closure = $this->getChildCallable();
         if ($this->isForkMode()) {
             $this->processManager->fork($closure);
         } else {
             $this->processManager->spawn($closure);
         }
     }
 }