NAME

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

VERSION

version 0.081

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

Reflex Reflex::Role::SigCatcher Reflex::Signal Reflex::Role::PidCatcher Reflex::PID

"ACKNOWLEDGEMENTS" in Reflex "ASSISTANCE" in Reflex "AUTHORS" in Reflex "BUGS" in Reflex "BUGS" in Reflex "CONTRIBUTORS" in Reflex "COPYRIGHT" in Reflex "LICENSE" in Reflex "TODO" in Reflex