Skip to content
Tris Forster edited this page Oct 18, 2016 · 1 revision

MultiProcess

The MultiProcess module uses a couple of FIFOs to manage a pool of workers. It handles respawning of workers if they die, though the manager process does not currently persist queued jobs.

Note PHP is not a great language for this kind of stuff. If you are using this for anything more than a basic work pool you should consider moving to something like Twisted Python or Node which are much more suited.

Basic Usage

You create a file containing all the functions you need

my_functions.php:

function say_hello($name) {
    return "Hello {$name}";
}

Then you are able to create a pool and call those functions

manager.php:

require_once "MultiProcess.php";

$results = array();
$mp = new MultiProcessManager('my_functions.php', 4);
$results[] = $mp->defer('say_hello', 'Andy');
$results[] = $mp->defer('say_hello', 'Bob');

$dl = new DeferedList($results);
$dl->addCallback('var_dump');

$mp->process();

Documentation

This is it at the moment. Have a look at MultiProcess.php.

Clone this wiki locally