Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created August 7, 2013 10:40
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 jnthn/6172985 to your computer and use it in GitHub Desktop.
Save jnthn/6172985 to your computer and use it in GitHub Desktop.
my @hunters;
for 1..4 -> $n {
@hunters.push(async { loop { last if (1..1000000).pick == 42 }; $n })
}
await Promise.anyof(@hunters);
say "Hunter " ~ @hunters.first(*.has_result).result ~ " got there first";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment