A worker component with object methods.
spawns a POE session and posts the initialize POE event to do initialization.
initialize
returns the object instance.
%options keys are as follows:
%options
alias => optional, string, POE session alias, defaults to stringified C<$self>
All other options keys will be saved and will be accessible via $obj->options as a hashref;
Posts the event $event_name and POE_args to $obj's session.
croaks on error
returns the object's session object.
Readonly accessor.
returns the object's options (hashref);
Options are the "remaining" data passed during spawn().
spawn()
returns the object session's POE ALIAS.
The alias may have been assigned during spawn().
gets called during the POE _stop handling phase.
_stop
Note that the session object will get garbage collected right after the call to this method. As per POE documentation, POE event posting done here will not be honored.
Called immediately after construction. Child classes generally override this method for the following reasons:
1. handle initialization based on $obj->options 2. add additional states to the current session via POE::Kernel->state()
As part of recommended practice, the component should not do any work in this state. Not until told to do so via start_work public state.
start_work
start_work an advisory event to the component for it to start working; i.e. to start its engines. The spawner session (i.e. the one who spawned the component) is the one who knows best when is the correct time to "start working".
A persistent component may simply choose to do some initialization here (read a file, connect to some host, etc.) and wait for work to be submitted via some other state.
Subclasses are required to override method.
Shuts down the component session. This is only necessary if the component has a persistent lifetime. That is, sessions that die naturally do not need to go through this shutdown process.
POE
POE::Kernel
POE::Session
POE::Component
Dexter Tad-y, <dtady@xyber.ph>
Copyright (C) 2008 by Dexter Tad-y
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Proc::Safetynet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Proc::Safetynet
CPAN shell
perl -MCPAN -e shell install Proc::Safetynet
For more information on module installation, please visit the detailed CPAN module installation guide.