Reflex::Role::SigCatcher - add signal catching behavior to a class
version 0.072
package Reflex::Signal; use Moose; extends 'Reflex::Base'; has signal => ( is => 'ro', isa => 'Str', required => 1, ); has active => ( is => 'ro', isa => 'Bool', default => 1, ); with 'Reflex::Role::SigCatcher' => { signal => 'signal', active => 'active', cb_signal => 'on_signal', method_start => 'start', method_stop => 'stop', method_pause => 'pause', method_resume => 'resume', }; 1;
Reflex::Role::SigCatcher is a Moose parameterized role that adds signal-catching behavior to Reflex based classes. The SYNOPSIS is the entire implementation of Reflex::SigCatcher, a simple class that allows Reflex::Role::SigCatcher to be used as an object.
Reflex::Role::SigCatcher is not suitable for SIGCHLD use. The specialized Reflex::Role::PidCatcher class is used for that, and it will automatically wait() for processes and return their exit statuses.
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.
signal sets the name of an attribute that will contain the signal name to catch. Signal names are as those found in %SIG.
signal
TODO - However, it may also be convenient to specify the signal name in the role's parameters. General use cases don't usually require signals names to change. The indirection through signal is currently useful for Reflex::Signal, however, so we probably need both modes. It might be better to provide two roles, one for each behavior, rather than one role that does both.
active specifies whether Reflex::Role::SigCatcher should be created in the active, signal-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.
active
Signal watchers may be paused and resumed. See method_pause and method_resume for ways to override the default method names.
method_pause
method_resume
cb_signal names the $self method that will be called whenever the signal named in <$self-$signal()>> is caught. It defaults to "on_%s_caught", where %s is the name of the signal. So if the INT signal is being watched, cb_signal will default to "on_INT_caught".
cb_signal
<$self-
method_start sets the name of the method that may be used to initially start catching signals. It's "start_%s" by default, where %s is the signal name being caught.
method_start
Reflex::Role::SigCatcher will automatically start watching for signals if the value of active's attribute is true.
method_stop may be used to permanently stop signal catchers. Stopped catchers cannot be restarted, so use method_pause if you need to temporarily disable signal watchers. method_resume may be used to resume them again.
method_stop
Signal catchers will automatically stop watching for signals upon DEMOLISH.
method_pause sets the name of the method that may be used to pause signal catching. It is "pause_%s" by default, where %s is the signal name being caught.
method_resume sets the name of the method that may be used to resume signal catching. It is "resume_%s" by default, where %s is the signal name being caught.
eg/eg-39-signals.pl shows how Reflex::Signal may be used with callbacks or promises.
Reflex::Signal is a simple class that watches for signals with Reflex::Role::SigCatcher.
Reflex 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
To install Reflex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflex
CPAN shell
perl -MCPAN -e shell install Reflex
For more information on module installation, please visit the detailed CPAN module installation guide.