AnyEvent::Worker::Pool - Easily create a pool of workers and use'em like a
single worker
use AnyEvent 5;
use AnyEvent::Worker::Pool;
# Create a pool of 2 workers
my $workers = AnyEvent::Worker::Pool->new( 2, @common_worker_init_args );
# Will be run instantly (left 1 idle worker)
$workers->do( @common_worker_do_args );
# Will be run instantly (left 0 idle workers)
$workers->do( @common_worker_do_args );
# Will be run after one of busy worker will get free
$workers->do( @common_worker_do_args );
$workers->take_worker(sub {
my $worker = shift;
$worker->do(@args, sub {
$workers>ret_worker($worker);
});
});
Mons Anderson, "<mons@cpan.org>"
Copyright 2009 Mons Anderson.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.