Event
view release on metacpan or search on metacpan
- Increase minimum version of perl to 5.006_003
- This test is too sensitive to load on the machine causing
random failures. Better to remove it from the regression test
battery.
1.10 2008-01-15
- min perl 5.006
- Skip bogus_fd test on darwin. Reported by schwern@pobox.com.
- Jerry D. Hedden <jdhedden@cpan.org> and Ãvar Arnfjörð
Bjarmason <avarab@gmail.com> correctly diagnosed that a recent
change in perl (#31130, FETCH/STORE/LENGTH callbacks for numbered capture
variables) caused $1 to loose its read-only-ness hence breaking test 6.
Zefram <zefram@fysh.org> suggested using $$ instead. I have not tested
this patch but it seems trivial enough.
1.09 2007-05-22
- doc git location git://nirmalvihar.info/home/joshua/event.git
1.08 2006-11-01
- Add casts to quell warnings as suggested by JDHEDDEN@cpan.org.
- Zombie events are still not being collected due to mysterious
refcnt problems. It is possible that this cannot be resolved
until perl implements tied hashes properly (through a VTBL!).
- Removed $Event::*::Count since it is superceded by
NetServer::ProcessTop.
0.08 1998-08-14
- C rewrite
0.07 1998-08-05
- test callbacks
- doc queuing
- remove debugging
0.06 1998-07-24
- parameterise register method so 'check' not fixed method but callback
- doc priorities
- doc callbacks
0.05 1998-07-20
- queuing, waiting
- Status method
0.04 1998-07-20
- registering forces class to be child of Event
- add waitForEvents
0.03 1998-07-18
typedef struct pe_tied pe_tied;
struct pe_tied {
pe_watcher base;
pe_timeable tm;
};
#define WKEYMETH(M) static void M(pe_watcher *ev, SV *nval)
#define EKEYMETH(M) static void M(pe_event *ev, SV *nval)
/* When this becomes a public API then we should also publish C interfaces
to set up perl & C callbacks. For now we can be lazy. */
struct pe_event_vtbl {
HV *stash;
pe_event *(*new_event)(pe_watcher *);
void (*dtor)(pe_event *);
pe_ring freelist;
};
struct pe_watcher_vtbl {
int did_require;
Tutorial.pdf view on Meta::CPAN
170 0 obj<</S/URI/URI(mailto:perl-loop@perl.org)>>endobj
171 0 obj<</Subtype/Link/Rect[166.0 528.3 251.5 540.3]/Border[0 0 0]/A 170 0 R>>endobj
172 0 obj<</S/URI/URI(mailto:perl@jochen-stenzel.de)>>endobj
173 0 obj<</Subtype/Link/Rect[36.0 355.7 143.7 367.7]/Border[0 0 0]/A 172 0 R>>endobj
174 0 obj[169 0 R
171 0 R
173 0 R
]endobj
175 0 obj<</Dests 176 0 R>>endobj
176 0 obj<</Kids[177 0 R]>>endobj
177 0 obj<</Limits[(a complete example)(writing callbacks)]/Names[(a complete example)178 0 R(a multiclient server)179 0 R(a watchers life cycle)180 0 R(about this document)181 0 R(advanced features)182 0 R(an overview of the event module)183 0 R(app...
178 0 obj<</D[259 0 R/XYZ null 286 null]>>endobj
179 0 obj<</D[328 0 R/XYZ null 427 null]>>endobj
180 0 obj<</D[274 0 R/XYZ null 371 null]>>endobj
181 0 obj<</D[412 0 R/XYZ null 545 null]>>endobj
182 0 obj<</D[352 0 R/XYZ null 855 null]>>endobj
183 0 obj<</D[244 0 R/XYZ null 855 null]>>endobj
184 0 obj<</D[400 0 R/XYZ null 855 null]>>endobj
185 0 obj<</D[394 0 R/XYZ null 437 null]>>endobj
186 0 obj<</D[388 0 R/XYZ null 531 null]>>endobj
187 0 obj<</D[358 0 R/XYZ null 433 null]>>endobj
lib/Event.pod view on Meta::CPAN
unloop('ok');
=head1 DESCRIPTION
ALERT: Marc Lehmann may have taken over the future of event loops in
Perl. Check out his libev library and EV Perl module. 25 Aug 2009
The Event module provide a central facility to watch for various types
of events and invoke a callback when these events occur. The idea is
to delay the handling of events so that they may be dispatched in
priority order when it is safe for callbacks to execute.
Events (in the ordinary sense of the word) are detected by B<watchers>,
which reify them as B<events> (in the special Event module sense).
For clarity,
the former type of events may be called "source events", and the latter
"target events". Source events, such as signals arriving, happen whether
or not they are being watched. If a source event occurs which a
watcher is actively watching then the watcher generates a corresponding
target event. Target events are only created by watchers. If several
watchers are interested in the same source event then each will
lib/Event.pod view on Meta::CPAN
case that an event is always pending at step 2 then I/O watchers will
starve. However, this is highly unlikely since async watchers should
never queue events so rapidly.
=item all_watchers()
Returns a list of all watchers (including stopped watchers).
=item all_running()
Returns a list of all watchers with actively running callbacks.
Watchers are returned in order of most recent to least recent.
=item all_idle()
Returns a list of all the idle watchers.
If the event queue is very busy, all the idle watchers will sit on the
idle queue waiting to run. However, be aware that if an idle watcher
has the C<max> attribute set then it will queue a normal event when
its C<max> wait time is exceeded.
lib/Event.pod view on Meta::CPAN
=item fd => $filehandle
This attribute can accept either a perl-esque filehandle or a system
call derived file descriptor number.
=item hard => $bool
Determines how repeating timers (or timeouts) are recalculated. The
timer is restarted either before or after the callback depending on
whether it is true or false, respectively. In long-running callbacks
this can make a significant difference.
=item interval => $seconds
How long between repeating timeouts. The C<at> attribute is
recalculated using C<interval> upon callback return.
=item max => $seconds
The maximum number of seconds to wait before triggering the callback.
lib/Event.pod view on Meta::CPAN
=item private => $anything
Use the C<private()> method to associate arbitrary data with a
watcher. This method is intended for implementers of watchers or
watcher subclasses. Each caller's package accesses its own private
attribute.
=item reentrant => $bool
By default, callbacks are allowed to invoke C<sweep> or C<loop> which
in turn may invoke the same callback again recursively. This can be
useful but can also be confusing. Moreover, if you keep reentering
callbacks you will quickly run out of stack space. Disable this
feature per watcher by setting reentrant to false. This will cause
the watcher to be suspended during recursive calls to C<sweep> or
C<loop>.
=item repeat => $bool
The repeat flag controls whether the callback should either be
one-shot or continue waiting for new events. The default setting
depends on the type of watcher. I<io>, I<signal>, and I<var> default
to true.
lib/Event.pod view on Meta::CPAN
------------- ----------------------------------------------
prepare returns minimum time to block (timeable)
check assess state after normal return from select/poll
asynccheck check for signals, etc
callback invoked before each event callback
=back
=head1 C API
Event also has a direct API for callbacks written exclusively in C.
See Event::MakeMaker.
=head1 WHAT ABOUT THREADS?
Event loops and threads are two different solutions to the same
problem: asynchronous processing. Event loops have been around since
the beginning of computing. They are well understood and proven to be
a good solution for many applications.
While event loops make use of basic operating system services, the
bulk of their implementation is usually outside the kernel. While an
event loop may appear to do many things in parallel, it does not, even
on multiprocessor hardware. Actions are always dispatched
sequentially. This implies that long running callbacks must be
avoided because otherwise event processing is halted.
Event loops work well when actions are short and to the point.
Long-running tasks must be broken into short steps and scheduled for
execution. Some sort of a state machine is usually required. While a
big, complex application server is usually simpler to implement in a
multithreaded fashion, a web browser can easily get by without
threads. Consider a JPEG file download and render. When some new
bytes are available they are sorted to the right place on the screen.
Only a little state must be kept to keep track of how much has been
lib/Event/generic.pod view on Meta::CPAN
=head1 DESCRIPTION
This module provides a watcher type within the C<Event> framework.
You must understand the architecture of the C<Event> system in order to
understand this document.
This module provides a system of reified event sources and watchers
watching those sources. Events are generated solely by a method on the
event source object. The events may carry arbitrary data to the event
handler callbacks. This module is intended for situations where the
events of interest are best determined by Perl code.
=head1 CLASSES
=over
=item Event::generic::Source
A reified event source.
# $Event::Eval = 1;
#$Event::DebugLevel = 0;
package myobj;
use Test;
my $myobj;
sub idle {
my ($o,$e) = @_;
if (!$myobj) {
# see if method callbacks work
ok $o, 'myobj';
ok $e->w->desc, __PACKAGE__;
}
++$myobj;
}
Event->idle(cb => [__PACKAGE__,'idle'],
desc => __PACKAGE__);
package main;
( run in 2.815 seconds using v1.01-cache-2.11-cpan-9b1e4054eb1 )