定制 webmaniacs.net/lib-fork 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webmaniacs.net/lib-fork

Composer 安装命令:

composer require webmaniacs.net/lib-fork

包简介

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

README 文档

README

Install the latest version with composer require webmaniacs.net/lib-fork

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";

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-19