Last active
March 22, 2018 17:02
-
-
Save JJ/47c5988e661291cab2691e9262992c17 to your computer and use it in GitHub Desktop.
(Failing) concurrent channels in perl6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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