Dexter Tad-y > Proc-Safetynet-0.04 > Proc::Safetynet::POEWorker

Download:
Proc-Safetynet-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

METHODS ^

A worker component with object methods.

CLASS->spawn( %options )

spawns a POE session and posts the initialize POE event to do initialization.

returns the object instance.

%options keys are as follows:

    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;

$obj->yield( $event_name, POE_args... )

Posts the event $event_name and POE_args to $obj's session.

croaks on error

$obj->session

returns the object's session object.

Readonly accessor.

$obj->options

returns the object's options (hashref);

Readonly accessor.

Options are the "remaining" data passed during spawn().

$obj->alias

returns the object session's POE ALIAS.

Readonly accessor.

The alias may have been assigned during spawn().

$obj->cleanup

gets called during the POE _stop handling phase.

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.

initialize

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.

shutdown

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.

SEE ALSO ^

POE

POE::Kernel

POE::Session

POE::Component

AUTHOR ^

Dexter Tad-y, <dtady@xyber.ph>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: