1AnyEvent::Impl::Perl(3)User Contributed Perl DocumentatioAnnyEvent::Impl::Perl(3)
2
3
4
6 AnyEvent::Impl::Perl - Pure-Perl event loop and AnyEvent adaptor for
7 itself
8
10 use AnyEvent;
11 # use AnyEvent::Impl::Perl;
12
13 # this module gets loaded automatically as required
14
15 # Explicit use:
16 use AnyEvent::Impl::Perl;
17 use AnyEvent;
18
19 ...
20
21 AnyEvent::Impl::Perl::loop; # run the event loop
22
24 This module provides transparent support for AnyEvent in case no other
25 event loop could be found or loaded. You don't have to do anything to
26 make it work with AnyEvent except by possibly loading it before
27 creating the first AnyEvent watcher.
28
29 If you want to use this module instead of autoloading another event
30 loop you can simply load it before creating the first watcher.
31
32 As for performance, this module is on par with (and usually faster
33 than) most select/poll-based C event modules such as Event or Glib (it
34 does not even come close to EV, though), with respect to I/O watchers.
35 Timers are handled less optimally, but for many common tasks, it's
36 still on par with event loops written in C.
37
38 This event loop has been optimised for the following use cases:
39
40 monotonic clock is available
41 This module will use the POSIX monotonic clock option (if it can be
42 detected at runtime) or the POSIX "times" function (if the
43 resolution is at least 100Hz), in which case it will not suffer
44 adversely from time jumps.
45
46 If no monotonic clock is available, this module will not attempt to
47 correct for time jumps in any way.
48
49 The clock chosen will be reported if the environment variable
50 $PERL_ANYEVENT_VERBOSE is set to 8 or higher.
51
52 any number of watchers on one fd
53 Supporting a large number of watchers per fd is purely a dirty
54 benchmark optimisation not relevant in practise. The more common
55 case of having one watcher per fd/poll combo is special-cased,
56 however, and therefore fast, too.
57
58 relatively few active fds per "select" call
59 This module expects that only a tiny amount of fds is active at any
60 one time. This is relatively typical of larger servers (but not the
61 case where "select" traditionally is fast), at the expense of the
62 "dense activity case" where most of the fds are active (which suits
63 "select").
64
65 The optimal implementation of the "dense" case is not much faster,
66 though, so the module should behave very well in most cases,
67 subject to the bad scalability of "select" in general.
68
69 lots of timer changes/iteration, or none at all
70 This module sorts the timer list using perl's "sort", even though a
71 total ordering is not required for timers.
72
73 This sorting is expensive, but means sorting can be avoided unless
74 the timer list has changed in a way that requires a new sort.
75
76 This means that adding lots of timers is very efficient, as well as
77 not changing the timers. Advancing timers (e.g. recreating a
78 timeout watcher on activity) is also relatively efficient, for
79 example, if you have a large number of timeout watchers that time
80 out after 10 seconds, then the timer list will be sorted only once
81 every 10 seconds.
82
83 This should not have much of an impact unless you have hundreds or
84 thousands of timers, though, or your timers have very small
85 timeouts.
86
88 The only user-visible function provided by this module is the "loop"
89 function:
90
91 AnyEvent::Impl::Perl::loop
92 Run the event loop, usually the last thing done in the main program
93 when you want to use the pure-perl backend.
94
96 AnyEvent.
97
99 Marc Lehmann <schmorp@schmorp.de>
100 http://home.schmorp.de/
101
102
103
104perl v5.12.1 2010-03-24 AnyEvent::Impl::Perl(3)