Skip to content

Instantly share code, notes, and snippets.

@JJ
Last active March 22, 2018 17:02
Show Gist options
  • Save JJ/47c5988e661291cab2691e9262992c17 to your computer and use it in GitHub Desktop.
Save JJ/47c5988e661291cab2691e9262992c17 to your computer and use it in GitHub Desktop.
(Failing) concurrent channels in perl6
my Channel $c .= new;
my Channel $c2 = $c.Supply.batch( elems => 2).Channel;
my $count = 0;
$c.send($_) for ^40;
my $work = start react whenever $c -> $item {
$c.send( $item );
say "This is $item";
}
my $more-work = start react whenever $c2 -> @item {
if ( $count++ < 100 ) {
$c.send( sum @item );
} else {
$c.close;
}
}
await $more-work;
.say for $c2.List;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment