Ko\ProcessManager::spawn PHP Method

spawn() public method

public spawn ( callable $callable ) : ko\Process
$callable callable Callable with prototype like function(Ko\Process $p) }
return ko\Process
    public function spawn(callable $callable)
    {
        return $this->internalSpawn($this->createProcess($callable));
    }

Usage Example

 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']);
 }
All Usage Examples Of Ko\ProcessManager::spawn