Created
March 18, 2014 12:20
-
-
Save Mons/9619022 to your computer and use it in GitHub Desktop.
AnyEvent cv
This file contains 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/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