## Install It's simple! Just use composer commands
composer require 'aoj/parallel-tasks:~1.0'
<?php
use AoJ\ParallelTasks\Task;
use AoJ\ParallelTasks\TaskRunner;
$tasks = [
new Task("sleep " . rand(1, 5)),
new Task("sleep " . rand(1, 5)),
new Task("sleep " . rand(1, 5)),
new Task("sleep " . rand(1, 5)),
];
$taskRunner = new TaskRunner($tasks, 2);
$taskRunner->run();
foreach($tasks as $task) {
var_dump($task->getResult());
}
or try
php example.php
run()
start taskssetParallel($newParallelCount)
set number of simultaneously process<integer>
getParallel()
### Task($cmd, $args = array(), $cwp = DIR)
run()
start process<bool>
isRunning()
check if process finished. You must run it beforegetResult()
<string>
getResult()
return stdout of process. Returns data continuously when it appears at stdout<integer|null>
getExitCode()
returns exit code of process. Returnsnull
if the process is still running or not yet started<integer>
getDuration()
Returns duration time in milliseconds, returns0
if process not yet started<integer>
getPid()
Returns process pid. Returns0
if process not yet started<string>
getCmd()
Returns command with arguments and without cwd
## TODO
- add tests, more tests
- update readme (see example.php for now)
- update