NAME

POE::Wheel::Spawner - A simple subprocess spawner

DESCRIPTION

POE::Wheel::Spawner starts on run only one subprocess for the workload. Until number of subprocesses does not exceed pool_size each subprocess can spawn another one.

VERSION

Version v0.03.1

SYNOPSIS

use POE::Wheel::Spawner;

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

$foo->run();

sub _workload {

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

    # ...
}

SUBROUTINES/METHODS

new(%arg)

Arguments:

  • pool_size

    the number of maximal parallel executed workload

  • stop_if_done

    stop after all pool_size pid's are exited.

    run endless if !stop_if_done

  • workload

    CODE reference to be executed

run(%arg)

optional %arg arguments for POE::Session:

  • debug

    default 0

  • trace

    default 0

create a POE::Session

run POE::Kernel

spawn($pid)

request to spawn

AUTHOR

Alexei Pastuchov <palik at cpan.org>.

REPOSITORY

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

LICENSE AND COPYRIGHT

Copyright 2014-2016 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.