The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POE::Component::WheelRun::Pool - POE::Wheel::Run worker pool

VERSION

version 0.001

SYNOPSIS

Provides a pool wrapper around POE::Wheel::Run to allow for large worker pools that are automatically replenished. POE::Component::WheelRun::Pool uses STDIN, STDOUT, and STDERR for communication between the parent session and the worker children.

my $worker_pool_id = POE::Component::WheelRun::Pool->spawn(
    Alias            => 'pool',             # Default
    Program          => \&run_analysis,     # Required
    PoolSize         => 4,                  # Default
    MaxTasksPerChild => 1000,               # Default '0' = unlimited
    MaxTimePerChild  => 3600,               # Default '0' = unlimited
    Splay            => 0.1,                # Default
    # Any Options from POE::Wheel::Run
    User     => 'bob',
    Group    => 'nobody',
    Priority => 5,
);

my $main = POE::Session->create(inline_states => {
    new_event => sub { $poe_kernel->post( pool => dispatch => @_[ARG0] ) },
});

This will create a pool of 4 workers with the run_analyze function as the entry point to the pool::dispatch event. Child processes should monitor STDIN for availability as the first thing attempted by the parent is an EOF on the STDIN of the child to let it know it should go away. Failing this, a kill() is called which is SIGINT by default.

FUNCTIONS

spawn()

Creates the worker pool and sets it ready for incoming tasks. POE::Component::WheelRun::Pool will pass sensible options from POE::Wheel::Run to the child process. See:

perldoc POE::Wheel::Run

For more information on options not covered here.

AUTHOR

Brad Lhotsky brad@divisionbyzero.net

COPYRIGHT AND LICENSE

This software is Copyright (c) 2016 by Brad Lhotsky.

This is free software, licensed under:

The (three-clause) BSD License

CONTRIBUTORS

SUPPORT

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Source Code

This module's source code is available by visiting: https://github.com/reyjrar/POE-Component-WheelRun-Pool