Skip to content

Instantly share code, notes, and snippets.

@tony-o
Created May 9, 2015 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony-o/0f8539d44a452d3765a8 to your computer and use it in GitHub Desktop.
Save tony-o/0f8539d44a452d3765a8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
my @p;
sub a (*@d) {
my $S;
my sub b(Int $sleep, Callable $r) {
$S = $sleep;
"SLEEP: $S".say;
@p.push(start {
sleep $S;
$r();
});
}
my sub c() {
$S.say;
};
EVAL 'b('~$_~', -> { c(); });' for @d;
}
a(1, 2);
await Promise.allof(@p);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment