Esempio n. 1
0
<?php

declare (ticks=1);
require_once __DIR__ . '/../vendor/autoload.php';
use Arara\Process\Child;
use Arara\Process\Control;
use Arara\Process\Pool;
use Arara\Test\TestAction;
$control = new Control();
$pool1 = new Pool(1);
$pool1->attach(new Child(new TestAction('11'), $control));
$pool1->attach(new Child(new TestAction('12'), $control));
$pool1->attach(new Child(new TestAction('13'), $control));
$pool1->attach(new Child(new TestAction('14'), $control));
$pool1->attach(new Child(new TestAction('15'), $control));
$pool2 = new Pool(3);
$pool2->attach(new Child(new TestAction('21'), $control));
$pool2->attach(new Child(new TestAction('22'), $control));
$pool2->attach(new Child(new TestAction('23'), $control));
$pool2->attach(new Child(new TestAction('24'), $control));
$pool2->attach(new Child(new TestAction('25'), $control));
$pool2->attach(new Child(new TestAction('26'), $control));
// Pools does not run into a different process
$pool = new Pool(5);
$pool->attach($pool1);
$pool->attach($pool2);
$pool->start();
$pool->wait();
Esempio n. 2
0
<?php

declare (ticks=1);
require_once __DIR__ . '/../vendor/autoload.php';
use Arara\Process\Child;
use Arara\Process\Control;
use Arara\Process\Pool;
use Arara\Test\TestAction;
$control = new Control();
$pool = new Pool(3);
$pool->attach(new Child(new TestAction(1), $control));
$pool->attach(new Child(new TestAction(2), $control));
$pool->attach(new Child(new TestAction(3), $control));
$pool->attach(new Child(new TestAction(4), $control));
$pool->attach(new Child(new TestAction(5), $control));
$pool->attach(new Child(new TestAction(6), $control));
$pool->attach(new Child(new TestAction(7), $control));
$pool->attach(new Child(new TestAction(8), $control));
$pool->attach(new Child(new TestAction(9), $control));
$pool->start();
$pool->wait();
Esempio n. 3
0
<?php

declare (ticks=1);
require_once __DIR__ . '/../vendor/autoload.php';
use Arara\Process\Child;
use Arara\Process\Control;
use Arara\Process\Pool;
use Arara\Test\TestAction;
$control = new Control();
$pool = new Pool(10);
$pool->start();
for ($index = 1; $index <= 9; $index++) {
    if (!$pool->isRunning()) {
        continue;
    }
    $action = new TestAction($index);
    $child = new Child($action, $control);
    $pool->attach($child);
    if (4 === $index) {
        $control->flush(0.5);
        $pool->terminate();
    }
}
Esempio n. 4
0
 public function testShouldNotWaitReapedProcessAtThePoolWhenTryingToWaitPool()
 {
     $process1 = $this->getMock('Arara\\Process\\Process');
     $process1->expects($this->any())->method('wait')->will($this->onConsecutiveCalls(true, false));
     $process2 = $this->getMock('Arara\\Process\\Process');
     $process2->expects($this->once())->method('wait')->will($this->returnValue(true));
     $pool = new Pool(2, true);
     $pool->attach($process1);
     $pool->attach($process2);
     $process1->wait();
     $pool->wait();
 }
Esempio n. 5
0
<?php

declare (ticks=1);
require_once __DIR__ . '/../vendor/autoload.php';
use Arara\Process\Child;
use Arara\Process\Control;
use Arara\Process\Pool;
use Arara\Test\TestAction;
$control = new Control();
$pool = new Pool(6);
$pool->start();
for ($index = 1; $index <= 3; $index++) {
    if (!$pool->isRunning()) {
        continue;
    }
    $action = new TestAction($index);
    $child = new Child($action, $control);
    $pool->attach($child);
}
$pool->wait();
echo 'Pool is not running anymore' . PHP_EOL;