Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created August 7, 2013 10:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jnthn/6172897 to your computer and use it in GitHub Desktop.
my $found = 0;
my $p10000 = async { (1..*).grep({ .is-prime && ++$found })[9999] };
loop {
say "Working ($found)...";
await Promise.anyof($p10000, Promise.sleep(1));
last if $p10000.has_result;
}
say $p10000.result;
Working (0)...
Working (259)...
Working (615)...
Working (1045)...
Working (1498)...
Working (2081)...
Working (2655)...
Working (3238)...
Working (3803)...
Working (4372)...
Working (4942)...
Working (5503)...
Working (6076)...
Working (6610)...
Working (7158)...
Working (7695)...
Working (8238)...
Working (8766)...
Working (9299)...
Working (9824)...
104729
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment