Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
use v6.d;
my Supplier $pinger .= new;
my Supplier $ponger .= new;
react {
say 'Beginning ping/pong...';
whenever $pinger.Supply.throttle: 1, 1 {
.say;
$ponger.emit: 'pong';
}
whenever $ponger.Supply.throttle: 1, 1 {
.say;
$pinger.emit: 'ping';
}
whenever Promise.in(10) {
exit 0;
}
$pinger.emit: 'ping';
}
use v6.d;
my Supplier::Preserving $pinger .= new;
my Supplier::Preserving $ponger .= new;
react {
ENTER {
say 'Beginning ping/pong...';
$pinger.emit: 'ping';
}
whenever $pinger.Supply.throttle: 1, 1 {
.say;
$ponger.emit: 'pong';
}
whenever $ponger.Supply.throttle: 1, 1 {
.say;
$pinger.emit: 'ping';
}
whenever Promise.in(10) {
exit 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment