Thread::Pool

Thread::Pool contains group of threads for performing similar jobs.
Download

Thread::Pool Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Elizabeth Mattijsen
  • Publisher web site:
  • http://search.cpan.org/~elizabeth/

Thread::Pool Tags


Thread::Pool Description

Thread::Pool contains group of threads for performing similar jobs. Thread::Pool contains group of threads for performing similar jobs.SYNOPSIS use Thread::Pool; $pool = Thread::Pool->new( { optimize => 'cpu', # default: 'memory' pre => sub {shift; print "starting worker with @_n", do => sub {shift; print "doing job for @_n"; reverse @_}, post => sub {shift; print "stopping worker with @_n", stream => sub {shift; print "streamline with @_n", monitor => sub { print "monitor with @_n", pre_post_monitor_only => 0, # default: 0 = also for "do" checkpoint => sub { print "checkpointingn" }, frequency => 1000, autoshutdown => 1, # default: 1 = yes workers => 10, # default: 1 maxjobs => 50, # default: 5 * workers minjobs => 5, # default: maxjobs / 2 }, qw(a b c) # parameters to "pre" and "post" routine ); $pool->job( qw(d e f) ); # not interested in result $jobid = $pool->job( qw(g h i) ); @result = $pool->result( $jobid ); # wait for result to be ready $jobid = $pool->job( qw(j k l) ); @result = $pool->result_dontwait( $jobid ); # do _not_ wait for result @result = $pool->waitfor( qw(m n o) ); # submit and wait for result $pool->add; # add worker(s) $pool->remove; # remove worker(s) $pool->workers( 10 ); # adapt number of workers $pool->join; # wait for all removed worker threads to finish $workers = $pool->workers; $todo = $pool->todo; $removed = $pool->removed; $pool->maxjobs( 100 ); # adapt or (de-)activate job throttling $pool->minjobs( 10 ); $pool->autoshutdown( 1 ); # shutdown when object is destroyed $pool->shutdown; # wait until all jobs done $pool->abort; # finish current job and remove all workers $done = $pool->done; # simple thread-use statistics $notused = $pool->notused; Thread::Pool->remove_me; # inside "do" onlyRequirements:· Perl


Thread::Pool Related Software