Skip to content

Instantly share code, notes, and snippets.

@Mons
Created March 18, 2014 12: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 Mons/9619022 to your computer and use it in GitHub Desktop.
Save Mons/9619022 to your computer and use it in GitHub Desktop.
AnyEvent cv
#!/usr/bin/env perl
use strict;
use 5.010;
use AnyEvent;
use Time::HiRes 'time';
sub async (&) {
my $code = shift;
my $t;$t = AE::timer 0,0,sub { undef $t;$code->(); }
}
my $cv = AE::cv;
for my $i (1..100) {
$cv->begin;
async {
say "$i done";
$cv->end;
};
if ($i % 10 == 0) {
#$cv->recv;
}
}
$cv->recv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment