/**
  * Create new execution context from pool options
  *
  * @param Pool $pool
  */
 public function __construct($pool)
 {
     $this->executionTimeout = $pool->getExecutionTimeout();
     $this->pollTimeout = $pool->getPollTimeout();
     $this->usleepTime = $pool->getSelectUsleepTime();
     $this->isSelectSupported = $pool->isSelectSupported();
     $this->isBlockingMode = $pool->isBlockingModeEnabled();
     $this->isDebugEnabled = $pool->isDebugEnabled();
     foreach ($pool->getCommands() as $command) {
         $this->procs[] = new Process($command);
     }
 }
Exemplo n.º 2
0
 public function testConstruct()
 {
     $pool = new Pool('some command');
     $this->assertEquals(count($pool->getCommands()), 1);
     $commands = $pool->getCommands();
     $this->assertEquals($commands[0]->getCommand(), 'some command');
     $pool = new Pool(['some command']);
     $this->assertEquals(count($pool->getCommands()), 1);
     $commands = $pool->getCommands();
     $this->assertEquals($commands[0]->getCommand(), 'some command');
     $pool = new Pool(['some command', 'another command']);
     $this->assertEquals(count($pool->getCommands()), 2);
     $commands = $pool->getCommands();
     $this->assertEquals($commands[0]->getCommand(), 'some command');
     $this->assertEquals($commands[1]->getCommand(), 'another command');
     $pool = new Pool([['some', 'command'], ['another', 'command']]);
     $this->assertEquals(count($pool->getCommands()), 2);
     $commands = $pool->getCommands();
     $this->assertEquals($commands[0]->getCommand(), 'some command');
     $this->assertEquals($commands[1]->getCommand(), 'another command');
     $cmd1 = new Command(['some', 'command']);
     $cmd2 = new Command(['another', 'command']);
     $pool = new Pool([$cmd1, $cmd2]);
     $this->assertEquals(count($pool->getCommands()), 2);
     $commands = $pool->getCommands();
     $this->assertEquals($commands[0]->getCommand(), 'some command');
     $this->assertEquals($commands[1]->getCommand(), 'another command');
 }