NAME

Poe::Wheel::Spawner

DESCRIPTION

Poe::Wheel::Spawner generate only one process for your workload and will add a next one on spawn call in it unless poos_size is not exceeded.

VERSION

Version 0.01

SYNOPSIS

use M43::POE::Wheel::Spawner;

my $foo = M43::POE::Wheel::Spawner->new(
            pool_size => 2,
            stop_if_done => 1,
            workload => sub { _workload() }
    );

$foo->run();

sub _workload {
    
    # request for a a new sibling
    $foo->spawn($$);

    # ...
}

SUBROUTINES/METHODS

new(%opts)

%opts keys:

pool_size

the number of maximal parallel executed workloads

stop_if_done

stop after pool_size pid's are exited.

run endless if !stop_if_done

workload

CODE reference to execute

run(%opts)

%opts provide to POE::Session

debug

default 0

trace

default 0

create a POE::Session

run POE::Kernel

spawn($pid)

print { busy_worker_pid => $pid } to stdout

_handle_start

handle _start and _next events defined in POE::Session, which is initialized in run.

start execution of workload by pool_size parallel running pids

_handle_sig_child

Clear heap. Trigger '_next' if !stop_if_done and currently no child is busy

_handle_done

is not implemented yet

_handle_stderr

provide STDERR to POE::Kernel::_warn

_handle_stdout

evaluate from child to stdout printed result.

trigger _next event if child asks - by using busy_worker_pid printed to stdout - for a sibling

AUTHOR

Alexei Pastuchov <palik at cpan.org>.

BUGS

Please report any bugs or feature requests to bug-poe-wheel-spawner at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Poe-Wheel-Spawner. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Poe::Wheel::Spawner

You can also look for information at:

REPOSITORY

https://github.com/p-alik/Poe-Wheel-Spawner.git

LICENSE AND COPYRIGHT

Copyright 2014 by Alexei Pastuchov <palik at cpan.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.