Jeff Rodriguez > Parallel-Fork-BossWorker-0.03 > Parallel::Fork::BossWorker

Download:
Parallel-Fork-BossWorker-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Module Version: 0.03   Source   Latest Release: Parallel-Fork-BossWorker-0.05

NAME ^

Parallel::Fork::BossWorker - Perl extension for easiliy creating forking queue processing applications.

SYNOPSIS ^

The 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 = new Parallel::Fork::BossWorker(
                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 = new Parallel::Fork::BossWorker(
                work_handler => sub {
                                my $work = shift;
                                ... do work here ...
                                return {result => "Looks good"};
                        },
                result_handler => sub {
                        my $result = shift;
                        print "$result->{result}\n";
                }
        );

DESCRIPTION ^

Parallel::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.

METHODS ^

new(...)

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();

REQUIREMENTS ^

This module depends on the following modules:

Carp

Data::Dumper

IO::Handle

BUGS ^

None I'm aware of yet, but I'm sure I'll receive reports :)

SEE ALSO ^

AUTHOR ^

Jeff Rodriguez, <jeff@jeffrodriguez.com>

COPYRIGHT AND LICENSE ^

Copyright (c) 2007, Jeff Rodriguez

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

   * Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.

   * Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.

   * Neither the name of the <ORGANIZATION> nor the names of its contributors
     may be used to endorse or promote products derived from this software
     without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax highlighting: