承接 cursedcoder/eprocess 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cursedcoder/eprocess

Composer 安装命令:

composer require cursedcoder/eprocess

包简介

Multi-threading framework?

README 文档

README

Build Status

The idea is to have multiple non-blocking contexts with a transparent inter-process communication out of the box.

This lib is just a PoC, use at your own risk.

Check out examples in examples/ dir.

Features

  • 3 adapters: child process (react), pthreads, symfony process (not tested)
  • inter-process communication between childs-parent using unix sockets
  • simple serialization for objects(jms serializer), arrays, scalars
  • async event-driven flow (react eventloop)
  • integration with frameworks, see EProcess\Application\ContainerApplication for Symfony
  • child workers can have own child workers (i.e. main -> worker -> worker ...)

Install&try

  • git clone https://github.com/cursedcoder/eprocess
  • cd eprocess
  • composer install
  • php examples/simple.php

Example explains features

Be aware this snippet below is only for explanatory reasons and will not work out (or at least yet).

For real examples see exampes/simple.php and related.

use EProcess\Application\Application;
use EProcess\Application\ApplicationFactory;

class Data
{
  // jms serializer metadata
  private $id;
  // setters getters etc.
}

class Main extends Application // like that one in c++
{
    public function run()
    {
        $worker = $this->createWorker(MyWorker::class); // create external non-blocking thread of MyWorker class
        $worker->send('any_event', 'Hello my worker!');
        $worker->on('hello_master', function() {
            // Receive back-call from child
        });
    }
}

class MyWorker extends Application
{
    public function run()
    {
        $this->on('any_event', function($data) {
            echo 'Got any_event event from my master: ' . $data; // data == Hello my worker
            // Still we can send any event back to master
            $this->send('hello_master');
            $this->send('send-any-data', new Data()); // you can send any object, array or scalar
            // object should have jms serializer metadata to be serialized
        });
        
        $this->getSubscribedEvents();
    }
}

ApplicationFactory::launch(Main::class);

You need to have proper autoloading established in order to use this example.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固