Skip to content

Instantly share code, notes, and snippets.

@Mons
Created Mar 18, 2014
Embed
What would you like to do?
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