No description, website, or topics provided.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/parent-child
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
.gitignore
META6.json
README.md

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.