NAME

Reflex::Role::PidCatcher - add async process reaping behavior to a class

VERSION

This document describes version 0.098, released on June 05, 2012.

SYNOPSIS

package Reflex::PID;

use Moose;
extends 'Reflex::Base';

has pid => (
	is        => 'ro',
	isa       => 'Int',
	required  => 1,
);

has active => (
	is      => 'ro',
	isa     => 'Bool',
	default => 1,
);

with 'Reflex::Role::PidCatcher' => {
	pid						=> 'pid',
	active        => 'active',
	cb_exit       => 'on_exit',
	method_start  => 'start',
	method_stop   => 'stop',
	method_pause  => 'pause',
	method_resume => 'resume',
};

1;

DESCRIPTION

Reflex::Role::PidCatcher is a Moose parameterized role that adds asynchronous child process reaping behavior to Reflex based classes. The SYNOPSIS is the entire implementation of Reflex::PID, a simple class that allows Reflex::Role::PidCatcher to be used as an object.

Required Role Parameters

None. All role parameters as of this writing have what we hope are sensible defaults. Please let us know if they don't seem all that sensible.

Optional Role Parameters

pid

pid sets the name of an attribute that will contain the process ID to wait for. Process IDs must be integers.

active

active specifies whether Reflex::Role::PidCatcher should be created in the active, process-watching state. All Reflex watchers are enabled by default. Set it to a false value, preferably 0, to initialize the catcher in an inactive or paused mode.

Process watchers may currently be paused and resumed, but this functionality may be dropped later. It's not good to leave child processes hanging. See method_pause and method_resume for ways to override the default method names.

cb_exit

cb_exit names the $self method that will be called when the child process identified in <$self-$pid()>> exits. It defaults to "on_%s_exit", where %s is the name of the PID attribute. For example, it will be "on_transcoder_exit" if the process ID is stored in a "transcoder" attribute.

method_start

method_start sets the name of the method that may be used to start watching for a process exit. It's "start_%s" by default, where %s is the name of the process ID's attribute.

Reflex::Role::PidCatcher will automatically start watching for its process ID if the value of active's attribute is true.

method_stop

method_stop may be used to permanently stop a process ID watcher. Stopped watchers cannot be restarted, so use method_pause if you need to temporarily disable them instead. method_resume may be used to resume them again.

Process ID catchers will automatically stop watching for process exit upon DEMOLISH.

method_pause

method_pause sets the name of the method that may be used to pause process catching. It is "pause_%s" by default, where %s is the name of the PID attribute.

method_resume

method_resume sets the name of the method that may be used to resume process reaping. It is "resume_%s" by default, where %s is the name of the attribute holding the process ID.

EXAMPLES

Reflex::Role::PidCatcher was initially written to support Reflex::PID, so there aren't many examples of the role's use by itself.

Reflex::POE::Wheel::Run actualy uses Reflex::PID.

eg/eg-07-wheel-run.pl uses Reflex::POE::Wheel::Run.

SEE ALSO

Please see those modules/websites for more information related to this module.

BUGS AND LIMITATIONS

You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Reflex.

AUTHOR

Rocco Caputo <rcaputo@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Rocco Caputo.

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

AVAILABILITY

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/Reflex/.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.