NAME
Thread::Pool::Simple - A simple thread-pool implementation
SYNOPSIS
use Thread::Pool::Simple;
my $pool = Thread::Pool::Simple->new(
min => 3, # at least 3 workers
max => 5, # at most 5 workers
load => 10, # increase worker if on average every worker has 10 jobs waiting
lifespan => 1000, # work retires after 1000 jobs
pre => \&pre_handle, # run before creating worker thread
do => \&do_handle, # job handler for each worker
post => \&post_handle, # run after worker threads end
);
my ($id1) = $pool->add(@arg1); #call in list context
my $id2) = $pool->add(@arg2); #call in scalar conetxt
$pool->add(@arg3) #call in void context
my @ret = $pool->remove($id1); #get result (block)
my $ret = $pool->remove_nb($id2); #get result (no block)
$pool->join(); #wait till all jobs are done
$pool->detach(); #don't wait.
DESCRIPTION
Thread::Pool::Simple
provides a simple thread-pool implementaion without external dependencies outside core modules.
Jobs can be submitted to and handled by multi-threaded `workers' managed by the pool.
AUTHOR
Jianyuan Wu, <jwu@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2007 by Jianyuan Wu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.