Created
July 25, 2011 07:20
-
-
Save treed/1103695 to your computer and use it in GitHub Desktop.
An Idea
This file contains hidden or 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
#!/usr/bin/perl | |
use Modern::Perl; | |
use Coro; | |
sub do_a_thing { | |
my @args = @_; | |
my $cb = pop @args; | |
async { | |
for my $thing (@args) { | |
say "Thing $thing"; | |
cede; | |
} | |
$cb->('done'); | |
}; | |
} | |
sub wait_call { | |
my ($sub, @args) = @_; | |
$sub->(@args, Coro::rouse_cb); | |
return Coro::rouse_wait; | |
} | |
async { | |
say 'this is async'; | |
cede; | |
say 'still async'; | |
}; | |
my @stuff = wait_call \&do_a_thing, 1, 2, 3; | |
say @stuff; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment