2017 © Pedro Peláez
 

library eprocess

Multi-threading framework?

image

cursedcoder/eprocess

Multi-threading framework?

  • Wednesday, April 13, 2016
  • by dark
  • Repository
  • 7 Watchers
  • 7 Stars
  • 44 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

EProcess

Build Status, (*1)

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

This lib is just a PoC, use at your own risk., (*3)

Check out examples in examples/ dir., (*4)

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)., (*5)

For real examples see exampes/simple.php and related., (*6)

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., (*7)

The Versions

04/04 2016
03/04 2016

0.0.7

0.0.7.0 https://github.com/cursedcoder/eprocess

Multi-threading framework?

  Sources   Download

MIT

The Requires

 

The Development Requires

async non-blocking react pthreads ipc child process

02/04 2016

0.0.6

0.0.6.0 https://github.com/cursedcoder/eprocess

Multi-threading framework?

  Sources   Download

MIT

The Requires

 

The Development Requires

async non-blocking react pthreads ipc child process

02/04 2016

0.0.4

0.0.4.0 https://github.com/cursedcoder/eprocess

Multi-threading framework?

  Sources   Download

MIT

The Requires

 

The Development Requires

async non-blocking react pthreads child process icp

21/09 2014

0.0.3

0.0.3.0 https://github.com/cursedcoder/eprocess

Multi-threading framework?

  Sources   Download

MIT

The Requires

 

The Development Requires

async non-blocking react pthreads child process icp

03/09 2014

0.0.2

0.0.2.0 https://github.com/cursedcoder/eprocess

Multi-threading framework?

  Sources   Download

MIT

The Requires

 

The Development Requires

async non-blocking react pthreads child process icp

02/09 2014

0.0.1

0.0.1.0 https://github.com/cursedcoder/eprocess

Multi-threading framework?

  Sources   Download

MIT

The Requires

 

The Development Requires

async non-blocking react pthreads child process icp