|
NAMEParallel::Fork::BossWorker - Perl extension for easiliy creating forking queue processing applications.SYNOPSISThe minimal usage of Parallel::Fork::BossWorker requires you supply the work_handler argument which returns a hash reference.use Parallel::Fork::BossWorker; # Create new BossWorker instance my $bw = Parallel::Fork::BossWorker->new( work_handler => sub { my $work = shift; ... do work here ... return {}; } ); $bw->add_work({key=>"value"}); $bw->process(); Additionally, you could specify the result_handler argument, which is passed the hash reference returned from your work_handler. use Parallel::Fork::BossWorker; # Create new BossWorker instance my $bw = Parallel::Fork::BossWorker->new( work_handler => sub { my $work = shift; ... do work here ... return {result => "Looks good"}; }, result_handler => sub { my $result = shift; print "$result->{result}\n"; } ); DESCRIPTIONParallel::Fork::BossWorker makes creating multiprocess applications easy.The module is designed to work in a queue style of setup; with the worker processes requesting 'work' from the boss process. The boss process transparently serializes and sends the work data to your work handler, to be consumed and worked. The worker process then transparently serializes and sends optional data back to the boss process to be handled in your result handler. This process repeats until the work queue is empty. METHODSnew(...)Creates and returns a new Parallel::Fork::BossWorker object.my $bw = Parallel::Fork::BossWorker->new(work_handler => \&routine) Parallel::Fork::BossWorker has options which allow you to customize how exactly the queue is handled and what is done with the data.
add_work(\%work)Adds work to the instance's queue.$bw->add_work({data => "my data"}); process()Forks off the child processes and begins processing data.$bw->process(); REQUIREMENTSThis module depends on the following modules:Carp Data::Dumper IO::Handle IO::Select BUGSIf we knew about any bugs, we would have fixed them. :)SEE ALSOAUTHORJeff Rodriguez, <jeff@jeffrodriguez.com>Tim Wilde, <twilde@cpan.org> COPYRIGHT AND LICENSECopyright (c) 2007, Jeff RodriguezPortions Copyright (c) 2011, Tim Wilde All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |