Skip to content

Instantly share code, notes, and snippets.

@skrisna
Created July 23, 2016 20:43
Show Gist options
  • Save skrisna/8c8dd495952d8beb0642531442898331 to your computer and use it in GitHub Desktop.
Save skrisna/8c8dd495952d8beb0642531442898331 to your computer and use it in GitHub Desktop.
my $channel = Channel.new;
await (^20).map: -> $r {
start {
#sleep (0,1,2).pick;
$channel.send({sleep 1; $r});
}
}
await (^3).map: -> $r {
start {
while $channel {
my $x = $channel.receive;
say "Worker $r: Consume $x()";
}
}
}
say now - INIT now;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment