symfony/symfony — pull request #8753 by romainneutron (2013-08-14 14:16:52+00:00)
Title: [Process][WIP] Add a Process Manager

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #8454
| License | MIT
| Doc PR | Not ready yet

Hello,

I'm looking for feedback for this process manager implementation.

This PR adds a [ProcessableInterface](https://github.com/romainneutron/symfony/blob/process-manager/src/Symfony/Component/Process/ProcessableInterface.php) that is implements by both `Process` and `ProcessManager`.

Once the API is ok, the remaining tasks are :
- [ ] Write documentation.
- [ ] Add more tests.

## Usage examples

### Run 4 jobs in parallel

```php
$manager = new Symfony\Component\Process\Manager\ProcessManager();
$manager
->add(new Process('...'))
->add(new Process('...'))
->add(new Process('...'))
->add(new Process('...'))
->run();
```

### Run 4 jobs in queue

```php
$manager = new Symfony\Component\Process\Manager\ProcessManager();
$manager
->setMaxParallelProcesses(1)
->add(new Process('...'))
->add(new Process('...'))
->add(new Process('...'))
->add(new Process('...'))
->run();
```

### Run 2 queues of 2 jobs parallely

```php
$queue1 = new Symfony\Component\Process\Manager\ProcessManager();
$queue1
->setMaxParallelProcesses(1)
->add(new Process('...'))
->add(new Process('...'));

$queue2 = new Symfony\Component\Process\Manager\ProcessManager();
$queue2
->setMaxParallelProcesses(1)
->add(new Process('...'))
->add(new Process('...'));

$manager = new Symfony\Component\Process\Manager\ProcessManager();
$manager
->add($queue1)
->add($queue2)
->run();
```