Skip to content

Instantly share code, notes, and snippets.

@JJ JJ/failing-c-channels.p6
Last active Mar 22, 2018

Embed
What would you like to do?
(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
You can’t perform that action at this time.