Created
November 29, 2011 09:14
-
-
Save Timbus/1404124 to your computer and use it in GitHub Desktop.
Think I got it...
This file contains 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 @q; | |
sub async(&f){ | |
push @q, $(gather {f({take $_})} ) | |
}; | |
sub yield { | |
for @q -> $l { | |
push @q, $l if $l.shift | |
} | |
} | |
for <a b c> -> $x { | |
async { | |
say $x; | |
$^yield(5); | |
say "unyeilded $x"; | |
} | |
} | |
say "Made 3 asyncs"; | |
yield(); | |
say "Back to main"; | |
yield(); | |
say "Done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./perl6 tgadsf.pl
Made 3 asyncs
a
b
c
Back to main
unyeilded a
unyeilded b
unyeilded c
Done