NAME

POE::Component::Runner - Create a session for running an arbitrary process.

SYNOPSIS

use POE qw( Component::Runner );

my %runner = (
    alias       => 'runner',
    function_rc => \&arbitrary_function,

    # optional
    callback_rh => {
        stdout => \&stdout_handler,
        stderr => \&stderr_handler,
        close  => \&close_handler,
        signal => \&signal_handler,
    },
    debug => 0,
);
POE::Component::Runner->new( \%runner );

  ...

POE::Kernel->post( runner => 'run', \@args );

  ...

POE::Kernel->post( runner => 'run', 'return_state', \@args );

  ...

my %baggage = (
    task_key => 'blah',    # optional task key used to reject redundant calls
);
POE::Kernel->post( runner => 'run', 'return_state', \@args, \%baggage );

The return_state handler will receive the @args and %baggage refs as ARG0, ARG1.

DESCRIPTION

This component provides a session with a 'run' state for facilitating asynchronous calls to otherwise blocking code. You can optionally provide callback handlers for the various underlying POE::Wheel::Run states.

Take a look in the example directory to see how to use it with POE::Component::DirWatch to asynchronously move files.

SEE ALSO

POE::Wheel::Run

ACKNOWLEDGEMENT

This module was inspired by the synopsis on Rocco Caputo's POE::Wheel::Run.

AUTHOR

Dylan Doxey, <dylan.doxey@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Dylan Doxey

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10 or, at your option, any later version of Perl 5 you may have available.