AnyEvent-Gearman-WorkerPool
view release on metacpan or search on metacpan
lib/AnyEvent/Gearman/WorkerPool.pm view on Meta::CPAN
my %conf = %{$self->conf($key)};
my $idle = 0;
my $running = 0;
foreach my $s ( @slots ){
$idle += $s->is_idle;
$running += $s->is_running;
}
DEBUG "[$key] idle: $idle, running: $running";
if( !$idle ){
if( $running < $conf{max} ){
DEBUG "expand $key";
my @stopped = grep{$_->is_stopped}@slots;
shift(@stopped)->start;
}
}
else{
if( $running > $conf{min} ){
DEBUG "reduce $key";
my @running = grep{$_->is_running}@slots;
pop(@running)->stop;
}
( run in 0.573 second using v1.01-cache-2.11-cpan-5623c5533a1 )