No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
examples/parent-child readme Dec 5, 2017
lib/Event/Emitter Merge branch 'master' of https://github.com/tony-o/perl6-event-emitte… Sep 26, 2018
t release time Sep 25, 2018
test release time Sep 25, 2018
.gitignore release time Sep 25, 2018
META6.json release time Sep 25, 2018
README.md release time Sep 25, 2018

README.md

Event::Emitter::Inter-Process

An extension to Event::Emitter that will allow you to communicate efficiently between processes.

Syntax

This module assumes you are familiar with (Event::Emitter)[https://github.com/tony-o/perl6-event-emitter]

Parent process

use Event::Emitter::Inter-Process;

my $event = Event::Emitter::Inter-Process.new;

my Proc::Async $child .=new(:w, 'perl6', '-Ilib', 'child.pl6');

$event.hook($child);

$event.on('echo', -> $data {
  # got $data from child;
  say $data.decode;
});

$child.start;
sleep 1;


$event.emit('echo'.encode, 'hello'.encode);
$event.emit('echo'.encode, 'world'.encode);

sleep 2;

Child process

use Event::Emitter::Inter-Process;

my $event = Event::Emitter::Inter-Process.new(:sub-process);

$event.on('echo', -> $data {
  "child echo: {$data.decode}".say;
  $event.emit('echo'.encode, $data);
});

sleep 3;
Parent output:
hello
world
Child output:
child echo: hello
child echo: world

License

Free for all.