Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

poe::component(3pm) [debian man page]

POE::Component(3pm)					User Contributed Perl Documentation				       POE::Component(3pm)

NAME
POE::Component - event driven objects or subsystems SYNOPSIS
See specific components. DESCRIPTION
POE "components" are event-driven modules that generally encapsulate mid- to high-level program features. For example, POE::Component::Client::DNS performs message-based asynchronous resolver lookups. POE::Component::Server::TCP is a basic asynchronous network server. The POE::Component namespace was started as place for contributors to publish their POE-based modules without requiring coordination with the main POE distribution. The namespace predates the -X convention, otherwise you'd be reading about POEx instead. As with many things in Perl, there is more than one way to implement component interfaces. Newer components sport OO interfaces, and some even use Moose, but older ones are solely message driven. OBJECT ORIENTED COMPONENTS
One way to create object-oriented components is to embed a POE::Session instance within an object. This is done by creating the session during the object's constructor, and setting the session's alias to a stringified version of the object reference. package Asynchrotron; sub new { my $class = shift; my $self = bless { }, $class; POE::Session->create( object_states => [ $self => { _start => "_poe_start", do_something => "_poe_do_something", }, ], ); return $self; } sub _poe_start { $_[KERNEL]->alias_set("$_[OBJECT]"); } The alias allows object methods to pass events into the session without having to store something about the session. The POE::Kernel call() transfers execution from the caller session's context into the component's session. sub do_something { my $self = shift; print "Inside the caller's session right now: @_ "; $poe_kernel->call("$self", "do_something", @_); } sub _poe_do_something { my @args = @_[ARG0..$#_]; print "Inside the component's session now: @args "; $_[OBJECT]{count}++; } Both $_[HEAP] and $_[OBJECT] are visible within the component's session. $_[HEAP] can be used for ultra-private encapsulation, while $_[OBJECT] may be used for data visible by accessors. sub get_count { my $self = shift; return $self->{count}; # $_[OBJECT]{count} above } Too many sessions may bog down object creation and destruction, so avoid creating them for every object. SEE ALSO
The SEE ALSO section in POE contains a table of contents covering the entire POE distribution. POE::Stage is a nascent project to formalize POE components, make POE::Kernel more object-oriented, and provide syntactic and semantic sugar for many common aspects of POE::Component development. It's also easier to type. Please investigate the project. Ideas and tuits are badly needed to help get the project off the ground. TO DO
Document the customary (but not mandatory!) process of creating and publishing a component. AUTHORS &; COPYRIGHTS Each component is written and copyrighted separately. Please see POE for more information about authors and contributors. perl v5.14.2 2012-05-15 POE::Component(3pm)

Check Out this Related Man Page

POE::Component::Client::MPD::Test(3pm)			User Contributed Perl Documentation		    POE::Component::Client::MPD::Test(3pm)

NAME
POE::Component::Client::MPD::Test - automate pococ-mpd testing VERSION
version 1.121670 SYNOPSIS
POE::Component::Client::MPD->spawn( ... ); POE::Component::Client::MPD::Test->new( { tests => [ [ 'event', [ $arg1, $arg2, ... ], $sleep, &check_results ], ... ] } ); POE::Kernel->run; DESCRIPTION
This module implements a POE::Session used to schedule tests according to a plan, calling hooks used to check whether a given test was successful. To use it, you need to first spawn a POE::Component::Client::MPD session - it's this session that will be tested. And don't forget to call POE's mainloop! Once started, it will fire the first event to the MPD session, wait for the return message, call the check callback, and wait a bit... before starting again with the next event in the list. When all events have been sent, the session will shut down itself. ATTRIBUTES
alias The session alias. Defaults to "tester". tests The list (array ref) of tests to run. It is required in the constructor call. Each list item is an array reference with the following sub- items: o event - the event to send to the POE::Component::Client::MPD session o args - event arguments (an array reference) o sleep - number of seconds to wait before calling next events o callback - a sub reference to check the results of current event. The real tests should be done in this sub. It will be called with the message received and the message payload. PUBLIC EVENTS ACCEPTED
next_test( ) Called to schedule the next test. mpd_result( $msg ) Called when mpd talks back, with $msg as a POE::Component::Client::MPD::Message param. AUTHOR
Jerome Quelin COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Jerome Quelin. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-15 POE::Component::Client::MPD::Test(3pm)
Man Page