Skip to content

Instantly share code, notes, and snippets.

@mala
Created September 24, 2009 05:31
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 mala/192543 to your computer and use it in GitHub Desktop.
Save mala/192543 to your computer and use it in GitHub Desktop.
use AnyEvent;
my $cv = AE::cv;
my $count = 0;
my $timer;
$timer = AE::timer 0, 0.1, sub {
$count++;
$cv->send("hoge" . $count);
if ($count > 10) {
$cv->send;
undef $timer;
}
};
my $gen;
$gen = sub {
my $data = $cv->recv;
# new cv
$cv = AE::cv;
unless ($data) {
warn "finish"; # last
return;
}
warn $data;
$gen->();
};
$gen->();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment