Perl Object Environment: Difference between revisions

Content deleted Content added
No edit summary
NotAG on AWB (talk | contribs)
replace {{manual}} with {{how-to}} per TfD
 
(24 intermediate revisions by 18 users not shown)
Line 1:
{{Short description|Library of modules (software)}}
: ''{{For |the Mach variant, see [[|Mach (kernel]]'')}}
 
{{Multiple issues|
The '''Perl Object Environment''' or '''POE''' is a [[Library (computer science)|library]] of Perl modules written in the [[Perl]] [[programming language]] by [[Rocco Caputo]] et al.
{{essay-like|date=October 2018}}
{{overly detailed|date=October 2018}}
{{how-to|article|date=January 2017}}
}}
The '''Perl Object Environment''' or ('''POE''') is a [[Librarylibrary (computer sciencecomputing)|library]] of Perl modules written in the [[Perl]] [[programming language]] by [[Rocco Caputo]] et al.
 
From CPAN:
:''"POE originally was developed as the core of a persistent object server and runtime environment. It has evolved into a general purpose multitasking and networking framework, encompassing and providing a consistent interface to other event [[Programevent loops|loopsloop]]s such as Event and the [[Tk (frameworksoftware)|Tk]] and [[GTK|Gtk]] toolkits."''
 
==POE Architecture: Layersand layers of Abstractionabstraction ==
POE, The '''Perl Object Environment''' can be thought of as a tiny modular [[operating system]]. One or more POE programs or instances can be run concurrently and are generally well suited for [[cooperative multitasking]]. The POE package consists of [[Namespacenamespace]]s and [[Abstraction (computer science)|namespacesabstractions]] and [[abstraction]]s that guide future development of POE in an open-ended [[CPAN|CPAN-style]] convention.
 
===The event layer===
The informal architecture consists of a set of layers with a [[Kernel (computeroperating sciencesystem)|kernel]] on the bottom. This tiny kernel represents the events layer which operates as the main loop of each running POE instance. The first call is to the "event dispatcher" - '''POE::Kernel'''.
 
The POE::Kernel namespace contains a suite of functions which are plugged-in tointo the kernel itself. These loop abstractions are designed after POE's standardized event loop bridge interface - '''POE::Loop'''. These can be mixed and matched as needed to provide runtime services and a lean facility for [[interprocess communication]]. The basic functions are '''POE::Loop::Event''', '''POE::Loop::Poll''' and '''POE::Loop::Select'''. Also available are '''POE::Loop::Tk''' and '''POE::Loop::Gtk''' thatwhich offer hooks into other loop bridges in the external environment. If that isn't enough, the POE::Loop kernel abstraction provides reusable signal callbacks, time or alarm callbacks, and filehandle activity callbacks as well as administrative functions such as initializing, executing, and finalizing event loops.
 
There is also a higher level packaging framework - POE::Macro and a debugging utility for testing them called POE::Preprocessor. This framework has yielded '''POE::Macro::UseBytes'''.
 
:NOTE: As the Perl tradition mandates, POE is also a moving target.
 
Always check [[CPAN]] to see what new goodies the community has placed in the archive.
(...and remember Perl's Motto: "There's more than one way to do it" per [[Larry Wall|Larry]])
 
The Running Kernel operates through primordial [[finite -state machine]]s constructed from another set of abstractions ruled by the '''POE::Session''' architecture. A POE::Session is almost trivially defined as a map of events to the functions, class [[Method (computer scienceprogramming)|methods]], and/or object methods that handle them. POE::Session objects also contain a storage space shared by all its event handlers, called a [[heap (programming)|heap]]. Any way you slice them the states are solidly identified and clearly defined.
 
A more featureful [[event handler]] is a POE::Session subclass called '''POE::NFA''' - an event-driven [[Nondeterministic finite Automatonautomaton]] (a ''smarter'' finite state machine). This event handler moves from one strictly defined state to another as events, polls, user selections, or other external events require. This [[finite-state machine|state machine]] acts to encapsulate a wide range of generic [[Event-driven programming|event driven]] [[thread (computer sciencecomputing)|threadthreads]]s allowing much tighter tracking along the [[execution path]] than the relatively informal POE::Session.
 
===The I/O Layerlayer===
The Kernel's next requirement is for Input-Output handlers that exist in a single I/O layer called ''Wheels''. Wheels initiate actions, handle their resulting low-level events, and produce higher-level events for the sessions that use them. Wheels, like Sessions and Loops are built from a uniform set of abstractions - '''POE::Wheel''' - that sit on top of the Kernel. There are seven highly specialized and well-defined Wheels in POE's base distribution:
*POE::Wheel::Run - Creates and interacts with child processes using pipe(), fork(), and sometimes exec(). Interaction is done through the child's standard input and output.
Line 33 ⟶ 38:
*POE::Wheel::ListenAccept - A subset of POE::Wheel::SocketFactory used for listening on existing server sockets and accepting connections from remote clients.
*POE::Wheel::ReadLine - A non-blocking, event driven analogue to Term::ReadLine.
*POE::Wheel::ReadWrite - A high-performance [[Asynchronous I/O|NBIO]] file handler for POE that uses POE's ''[[softwaredevice driver|driverdrivers]]s'' and ''[[filter (software)|filter]]s'' to perform buffered read and write on '''[[filehandle]]s''' which draws on the next layer - POE's own little file system.
 
===The file layers===
Line 47 ⟶ 52:
*'''POE::Filter::Stream''' - does nothing. It merely passes data through without any change.
 
see [http://search.cpanmetacpan.org/~rcaputomodule/POE/lib/POE.pm POE at CPAN] for the complete list
 
==POE Components==
Several larger [[Modular programming|packages]] have been written in POE according to the '''POE::Component''' documentation. These are event-driven modules, many of which act as little [[Daemon (computer softwarecomputing)|daemons]] that provide services to larger packages to which they belong. Some of them facilitate higher-level communications between modules, especially stand-alone applications that need to remain independent from the main distribution of Perl.
 
In general, POE Components are ready-made high level procedures that perform specific large tasks. A few examples:
Line 63 ⟶ 68:
This should be true for any library, though."
 
==POE Humor==
* The [http://search.cpan.org/perldoc?Acme%3A%3APOE%3A%3AKnee Acme::POE::Knee] module on the [[CPAN]].
* A number of silly acronym expansions at the end of [http://poe.perl.org/?What_POE_IS What POE Is].
 
==See also==
Line 73 ⟶ 78:
==External links==
*[http://poe.perl.org/ POE Home Page] (a Wiki site)
*[http://poe.perl.org/?POE_Cookbook The POE_Cookbook]
*[http://search.cpan.org/~rcaputo/POE/ POE at CPAN]
*[http://search.cpan.org/search?m=module&q=POE%3A%3AComponent POE Component classes at CPAN]
*[http://www.perl.com/pub/a/2001/01/poe.html A Beginner's Introduction to POE]
*[http://poe.perl.org/?Evolution_of_a_POE_Server Evolution_of_a_POE_Server]
*[http://www.stonehenge.com/merlyn/LinuxMag/col41.html merlyn (stonehenge) article]
 
[[Category:Perl modules]]
[[Category:Perl software]]
[[Category:Perl modules]]
 
[[zh:Perl Object Environment]]