2017 © Pedro Peláez
 

library lib-fork

Lib fork processes in PHP and allow multi-threading. Inspired by duncan3dc/fork-helper

image

webmaniacs.net/lib-fork

Lib fork processes in PHP and allow multi-threading. Inspired by duncan3dc/fork-helper

  • Friday, March 20, 2015
  • by stas-dovgodko
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

lib-fork

Install the latest version with composer require webmaniacs.net/lib-fork, (*1)

Examples

$manager = new \wmlib\fork\Manager(function(array $error) {
    print_r($error);
    die('Child process error');
});
$manager->setNotifier($notifier = new \wmlib\fork\Notifier\Shm());

$manager->child(function (\wmlib\fork\INotifier $notifier, $var) {
    echo 'Start '.getmypid()."\n";
    echo 'Echo from child process with '.$var.' value!';
    sleep(1);
    echo 'End '.getmypid()."\n";
}, ['var' => 'value']);

while($manager->loop(10)) {
    // run 10 forked childs in infinite loop
    // Manager will handle childs count
    usleep(10000);
}
echo "End\n";

The Versions

20/03 2015

dev-master

9999999-dev

Lib fork processes in PHP and allow multi-threading. Inspired by duncan3dc/fork-helper

  Sources   Download

MIT

The Requires

  • ext-pcntl *
  • php >=5.5.0

 

The Development Requires

by Stas Dovgodko

process control pcntl fork multi-threading