Created
May 19, 2011 23:09
-
-
Save athomason/981997 to your computer and use it in GitHub Desktop.
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
use strict; | |
use warnings; | |
use AnyEvent; | |
use AnyEvent::Gearman::Client; | |
my $count = shift || 1000; | |
my $client = AnyEvent::Gearman::Client->new(job_servers => ['127.0.0.1:7003']); | |
my $cv = AnyEvent->condvar; | |
my $done = 0; | |
sub done { | |
$cv->send if ++$done > $count; | |
new(); | |
} | |
sub new { | |
$client->add_task( | |
test => 1 => | |
on_complete => \&done, | |
on_error => \&done, | |
); | |
} | |
new(); | |
$cv->recv; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment