Skip to content

Instantly share code, notes, and snippets.

@berekuk
Created May 28, 2013 09:04
Show Gist options
  • Select an option

  • Save berekuk/5661492 to your computer and use it in GitHub Desktop.

Select an option

Save berekuk/5661492 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Coro;
use Coro::AnyEvent;
my $param;
sub param {
return $param;
}
sub route {
Coro::AnyEvent::sleep 1;
print param, "\n";
}
sub req {
my ($arg) = @_;
return async {
$param = $arg;
route;
};
}
my @c = map { req("foo$_") } (1..5);
$_->join for @c;
foo5
foo5
foo5
foo5
foo5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment