Skip to content

Instantly share code, notes, and snippets.

@Timbus
Created November 29, 2011 09: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 Timbus/1404124 to your computer and use it in GitHub Desktop.
Save Timbus/1404124 to your computer and use it in GitHub Desktop.
Think I got it...
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";
@Timbus
Copy link
Author

Timbus commented Nov 29, 2011

./perl6 tgadsf.pl
Made 3 asyncs
a
b
c
Back to main
unyeilded a
unyeilded b
unyeilded c
Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment