>>>>> "Michael" == Michael C Davis <[EMAIL PROTECTED]> writes:

Michael> At 09:52 AM 3/9/04 -0700, Wiggins d Anconia wrote:
>> ...
>> a framework for handling time slicing, or event
>> programming tasks, or multi-tasking processes

Michael> If that's what it is, these terms localize it pretty well for me. "An
Michael> event-based framework for handling time-slicing in multitasking processes."

"An event loop on steroids"

Most of us have written programs to do many things, but usually in an
orderly fashion.  If you've ever found yourself writing a program that
was trying to do many things *at once* in an orderly fashion, you'll
want an event loop.  An event loop associates reactions with each of a
set of actions of interest.

A simple version of this might be like trying to watch two growing
files at once, and interleaving the results into one larger file.
With "simple" Perl, this is pretty hard, because you don't have
asynchronous I/O.  With POE, you can grab the lines from "both" files
at the "same" time in an orderly way, performing identical or distinct
actions as each line is seen.

For example, in
<http://www.stonehenge.com/merlyn/PerlJournal/col01.html>, I used POE
to write a process that tails a file, noting the time at which each
line appears, and in parallel also responding to one (or many) web
browsers as a web server, delivering a color-coded version of the
trailing lines of the file.  In
<http://www.stonehenge.com/merlyn/LinuxMag/col41.html>, I used POE in
a parallel link checker, overlapping DNS lookups with page fetch
response times to fetch things three to ten times faster in a single
process than I might have done without POE.  In
<http://www.stonehenge.com/merlyn/PerlJournal/col09.html>, I tail a
logfile (I do that a lot :) and deliver it to an IRC channel,
throttled appropriately so that I don't get booted off for channel
flooding.

POE is like forking, without the complete separation of data
and troublesome IPC issues.

POE is like threads, but with built-in data locking.

POE requires some discipline, but can be very powerful when used
correctly.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to