Skip to content

Instantly share code, notes, and snippets.

@treed
Created July 25, 2011 07:20
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 treed/1103695 to your computer and use it in GitHub Desktop.
Save treed/1103695 to your computer and use it in GitHub Desktop.
An Idea
#!/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