Thread::WorkersCreates a "boss" which feeds a queue, which is serviced by a pool of threads called "wor... | |
Download |
Thread::Workers Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Kal Aeolian
- Publisher web site:
- http://search.cpan.org/~panikal/
Thread::Workers Tags
Thread::Workers Description
Thread::Workers is a Perl module that utilizes threads, Thread::Sempahore, and Thread::Queue to create a pool of workers which are serviced with work by a boss thread. The boss thread could be fed data from a socket listening on the master thread, or could have a routine to check a database for work.SYNOPSIS use Thread::Workers; my $pool = Thread::Workers->new(); $pool->set_boss_fetch_cb(\&function_returns_work); $pool->set_boss_log_cb(\&function_processes_worker_returns); $pool->set_worker_work_cb(\&function_does_work); $pool->start_boss(); $pool->start_workers(); $pool->add_worker(); $pool->sleep_workers(); $pool->wake_workers(); #internal control loops # we have orders to increase the load! add 500 workers for (1..500) { $pool->add_worker(); } #time to cleanup $pool->stop_boss(); #signal boss thread to die $pool->stop_workers(); #stop the workers, may leave unfinished items in queue. # Or! $pool->stop_finish_work(); #gracefully stop boss and finish work queue, then shut down workers.Product's homepage
Thread::Workers Related Software