ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/README
(Generate patch)

Comparing AnyEvent/README (file contents):
Revision 1.18 by root, Thu Apr 24 09:13:26 2008 UTC vs.
Revision 1.19 by root, Mon Apr 28 08:02:14 2008 UTC

1NAME 1NAME
2 AnyEvent - provide framework for multiple event loops 2 AnyEvent - provide framework for multiple event loops
3 3
4 EV, Event, Coro::EV, Coro::Event, Glib, Tk, Perl, Event::Lib, Qt - 4 EV, Event, Coro::EV, Coro::Event, Glib, Tk, Perl, Event::Lib, Qt, POE -
5 various supported event loops 5 various supported event loops
6 6
7SYNOPSIS 7SYNOPSIS
8 use AnyEvent; 8 use AnyEvent;
9 9
76 module. 76 module.
77 77
78 During the first call of any watcher-creation method, the module tries 78 During the first call of any watcher-creation method, the module tries
79 to detect the currently loaded event loop by probing whether one of the 79 to detect the currently loaded event loop by probing whether one of the
80 following modules is already loaded: Coro::EV, Coro::Event, EV, Event, 80 following modules is already loaded: Coro::EV, Coro::Event, EV, Event,
81 Glib, Tk, Event::Lib, Qt. The first one found is used. If none are 81 Glib, AnyEvent::Impl::Perl, Tk, Event::Lib, Qt, POE. The first one found
82 found, the module tries to load these modules (excluding Event::Lib and 82 is used. If none are found, the module tries to load these modules
83 Qt) in the order given. The first one that can be successfully loaded 83 (excluding Tk, Event::Lib, Qt and POE as the pure perl adaptor should
84 will be used. If, after this, still none could be found, AnyEvent will 84 always succeed) in the order given. The first one that can be
85 fall back to a pure-perl event loop, which is not very efficient, but 85 successfully loaded will be used. If, after this, still none could be
86 should work everywhere. 86 found, AnyEvent will fall back to a pure-perl event loop, which is not
87 very efficient, but should work everywhere.
87 88
88 Because AnyEvent first checks for modules that are already loaded, 89 Because AnyEvent first checks for modules that are already loaded,
89 loading an event model explicitly before first using AnyEvent will 90 loading an event model explicitly before first using AnyEvent will
90 likely make that model the default. For example: 91 likely make that model the default. For example:
91 92
130 131
131 Note that "my $w; $w =" combination. This is necessary because in Perl, 132 Note that "my $w; $w =" combination. This is necessary because in Perl,
132 my variables are only visible after the statement in which they are 133 my variables are only visible after the statement in which they are
133 declared. 134 declared.
134 135
135 IO WATCHERS 136 I/O WATCHERS
136 You can create an I/O watcher by calling the "AnyEvent->io" method with 137 You can create an I/O watcher by calling the "AnyEvent->io" method with
137 the following mandatory key-value pairs as arguments: 138 the following mandatory key-value pairs as arguments:
138 139
139 "fh" the Perl *file handle* (*not* file descriptor) to watch for events. 140 "fh" the Perl *file handle* (*not* file descriptor) to watch for events.
140 "poll" must be a string that is either "r" or "w", which creates a 141 "poll" must be a string that is either "r" or "w", which creates a
141 watcher waiting for "r"eadable or "w"ritable events, respectively. "cb" 142 watcher waiting for "r"eadable or "w"ritable events, respectively. "cb"
142 is the callback to invoke each time the file handle becomes ready. 143 is the callback to invoke each time the file handle becomes ready.
143 144
144 As long as the I/O watcher exists it will keep the file descriptor or a 145 Although the callback might get passed parameters, their value and
145 copy of it alive/open. 146 presence is undefined and you cannot rely on them. Portable AnyEvent
147 callbacks cannot use arguments passed to I/O watcher callbacks.
146 148
149 The I/O watcher might use the underlying file descriptor or a copy of
147 It is not allowed to close a file handle as long as any watcher is 150 it. You must not close a file handle as long as any watcher is active on
148 active on the underlying file descriptor. 151 the underlying file descriptor.
149 152
150 Some event loops issue spurious readyness notifications, so you should 153 Some event loops issue spurious readyness notifications, so you should
151 always use non-blocking calls when reading/writing from/to your file 154 always use non-blocking calls when reading/writing from/to your file
152 handles. 155 handles.
153 156
163 TIME WATCHERS 166 TIME WATCHERS
164 You can create a time watcher by calling the "AnyEvent->timer" method 167 You can create a time watcher by calling the "AnyEvent->timer" method
165 with the following mandatory arguments: 168 with the following mandatory arguments:
166 169
167 "after" specifies after how many seconds (fractional values are 170 "after" specifies after how many seconds (fractional values are
168 supported) should the timer activate. "cb" the callback to invoke in 171 supported) the callback should be invoked. "cb" is the callback to
169 that case. 172 invoke in that case.
173
174 Although the callback might get passed parameters, their value and
175 presence is undefined and you cannot rely on them. Portable AnyEvent
176 callbacks cannot use arguments passed to time watcher callbacks.
170 177
171 The timer callback will be invoked at most once: if you want a repeating 178 The timer callback will be invoked at most once: if you want a repeating
172 timer you have to create a new watcher (this is a limitation by both Tk 179 timer you have to create a new watcher (this is a limitation by both Tk
173 and Glib). 180 and Glib).
174 181
218 SIGNAL WATCHERS 225 SIGNAL WATCHERS
219 You can watch for signals using a signal watcher, "signal" is the signal 226 You can watch for signals using a signal watcher, "signal" is the signal
220 *name* without any "SIG" prefix, "cb" is the Perl callback to be invoked 227 *name* without any "SIG" prefix, "cb" is the Perl callback to be invoked
221 whenever a signal occurs. 228 whenever a signal occurs.
222 229
230 Although the callback might get passed parameters, their value and
231 presence is undefined and you cannot rely on them. Portable AnyEvent
232 callbacks cannot use arguments passed to signal watcher callbacks.
233
223 Multiple signal occurances can be clumped together into one callback 234 Multiple signal occurances can be clumped together into one callback
224 invocation, and callback invocation will be synchronous. synchronous 235 invocation, and callback invocation will be synchronous. synchronous
225 means that it might take a while until the signal gets handled by the 236 means that it might take a while until the signal gets handled by the
226 process, but it is guarenteed not to interrupt any other callbacks. 237 process, but it is guarenteed not to interrupt any other callbacks.
227 238
240 251
241 The child process is specified by the "pid" argument (if set to 0, it 252 The child process is specified by the "pid" argument (if set to 0, it
242 watches for any child process exit). The watcher will trigger as often 253 watches for any child process exit). The watcher will trigger as often
243 as status change for the child are received. This works by installing a 254 as status change for the child are received. This works by installing a
244 signal handler for "SIGCHLD". The callback will be called with the pid 255 signal handler for "SIGCHLD". The callback will be called with the pid
245 and exit status (as returned by waitpid). 256 and exit status (as returned by waitpid), so unlike other watcher types,
257 you *can* rely on child watcher callback arguments.
246 258
247 Example: wait for pid 1333 259 There is a slight catch to child watchers, however: you usually start
260 them *after* the child process was created, and this means the process
261 could have exited already (and no SIGCHLD will be sent anymore).
262
263 Not all event models handle this correctly (POE doesn't), but even for
264 event models that *do* handle this correctly, they usually need to be
265 loaded before the process exits (i.e. before you fork in the first
266 place).
267
268 This means you cannot create a child watcher as the very first thing in
269 an AnyEvent program, you *have* to create at least one watcher before
270 you "fork" the child (alternatively, you can call "AnyEvent::detect").
271
272 Example: fork a process and wait for it
273
274 my $done = AnyEvent->condvar;
275
276 AnyEvent::detect; # force event module to be initialised
277
278 my $pid = fork or exit 5;
248 279
249 my $w = AnyEvent->child ( 280 my $w = AnyEvent->child (
250 pid => 1333, 281 pid => $pid,
251 cb => sub { 282 cb => sub {
252 my ($pid, $status) = @_; 283 my ($pid, $status) = @_;
253 warn "pid $pid exited with status $status"; 284 warn "pid $pid exited with status $status";
285 $done->broadcast;
254 }, 286 },
255 ); 287 );
288
289 # do something else, then wait for process exit
290 $done->wait;
256 291
257 CONDITION VARIABLES 292 CONDITION VARIABLES
258 Condition variables can be created by calling the "AnyEvent->condvar" 293 Condition variables can be created by calling the "AnyEvent->condvar"
259 method without any arguments. 294 method without any arguments.
260 295
338 AnyEvent::Impl::CoroEV based on Coro::EV, best choice. 373 AnyEvent::Impl::CoroEV based on Coro::EV, best choice.
339 AnyEvent::Impl::CoroEvent based on Coro::Event, second best choice. 374 AnyEvent::Impl::CoroEvent based on Coro::Event, second best choice.
340 AnyEvent::Impl::EV based on EV (an interface to libev, best choice). 375 AnyEvent::Impl::EV based on EV (an interface to libev, best choice).
341 AnyEvent::Impl::Event based on Event, second best choice. 376 AnyEvent::Impl::Event based on Event, second best choice.
342 AnyEvent::Impl::Glib based on Glib, third-best choice. 377 AnyEvent::Impl::Glib based on Glib, third-best choice.
378 AnyEvent::Impl::Perl pure-perl implementation, inefficient but portable.
343 AnyEvent::Impl::Tk based on Tk, very bad choice. 379 AnyEvent::Impl::Tk based on Tk, very bad choice.
344 AnyEvent::Impl::Perl pure-perl implementation, inefficient but portable.
345 AnyEvent::Impl::Qt based on Qt, cannot be autoprobed (see its docs). 380 AnyEvent::Impl::Qt based on Qt, cannot be autoprobed (see its docs).
346 AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. 381 AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse.
382 AnyEvent::Impl::POE based on POE, not generic enough for full support.
383
384 There is no support for WxWidgets, as WxWidgets has no support for
385 watching file handles. However, you can use WxWidgets through the
386 POE Adaptor, as POE has a Wx backend that simply polls 20 times per
387 second, which was considered to be too horrible to even consider for
388 AnyEvent. Likewise, other POE backends can be used by AnyEvent by
389 using it's adaptor.
390
391 AnyEvent knows about Prima and Wx and will try to use POE when
392 autodetecting them.
347 393
348 AnyEvent::detect 394 AnyEvent::detect
349 Returns $AnyEvent::MODEL, forcing autodetection of the event model 395 Returns $AnyEvent::MODEL, forcing autodetection of the event model
350 if necessary. You should only call this function right before you 396 if necessary. You should only call this function right before you
351 would have created an AnyEvent watcher anyway, that is, as late as 397 would have created an AnyEvent watcher anyway, that is, as late as
390 436
391 You can chose to use a rather inefficient pure-perl implementation by 437 You can chose to use a rather inefficient pure-perl implementation by
392 loading the "AnyEvent::Impl::Perl" module, which gives you similar 438 loading the "AnyEvent::Impl::Perl" module, which gives you similar
393 behaviour everywhere, but letting AnyEvent chose is generally better. 439 behaviour everywhere, but letting AnyEvent chose is generally better.
394 440
441OTHER MODULES
442 The following is a non-exhaustive list of additional modules that use
443 AnyEvent and can therefore be mixed easily with other AnyEvent modules
444 in the same program. Some of the modules come with AnyEvent, some are
445 available via CPAN.
446
447 AnyEvent::Util
448 Contains various utility functions that replace often-used but
449 blocking functions such as "inet_aton" by event-/callback-based
450 versions.
451
452 AnyEvent::Handle
453 Provide read and write buffers and manages watchers for reads and
454 writes.
455
456 AnyEvent::Socket
457 Provides a means to do non-blocking connects, accepts etc.
458
459 AnyEvent::HTTPD
460 Provides a simple web application server framework.
461
462 AnyEvent::DNS
463 Provides asynchronous DNS resolver capabilities, beyond what
464 AnyEvent::Util offers.
465
466 AnyEvent::FastPing
467 The fastest ping in the west.
468
469 Net::IRC3
470 AnyEvent based IRC client module family.
471
472 Net::XMPP2
473 AnyEvent based XMPP (Jabber protocol) module family.
474
475 Net::FCP
476 AnyEvent-based implementation of the Freenet Client Protocol,
477 birthplace of AnyEvent.
478
479 Event::ExecFlow
480 High level API for event-based execution flow control.
481
482 Coro
483 Has special support for AnyEvent.
484
485 IO::Lambda
486 The lambda approach to I/O - don't ask, look there. Can use
487 AnyEvent.
488
489 IO::AIO
490 Truly asynchronous I/O, should be in the toolbox of every event
491 programmer. Can be trivially made to use AnyEvent.
492
493 BDB Truly asynchronous Berkeley DB access. Can be trivially made to use
494 AnyEvent.
495
395SUPPLYING YOUR OWN EVENT MODEL INTERFACE 496SUPPLYING YOUR OWN EVENT MODEL INTERFACE
396 This is an advanced topic that you do not normally need to use AnyEvent 497 This is an advanced topic that you do not normally need to use AnyEvent
397 in a module. This section is only of use to event loop authors who want 498 in a module. This section is only of use to event loop authors who want
398 to provide AnyEvent compatibility. 499 to provide AnyEvent compatibility.
399 500
437 538
438ENVIRONMENT VARIABLES 539ENVIRONMENT VARIABLES
439 The following environment variables are used by this module: 540 The following environment variables are used by this module:
440 541
441 "PERL_ANYEVENT_VERBOSE" 542 "PERL_ANYEVENT_VERBOSE"
543 By default, AnyEvent will be completely silent except in fatal
544 conditions. You can set this environment variable to make AnyEvent
545 more talkative.
546
547 When set to 1 or higher, causes AnyEvent to warn about unexpected
548 conditions, such as not being able to load the event model specified
549 by "PERL_ANYEVENT_MODEL".
550
442 When set to 2 or higher, cause AnyEvent to report to STDERR which 551 When set to 2 or higher, cause AnyEvent to report to STDERR which
443 event model it chooses. 552 event model it chooses.
444 553
445 "PERL_ANYEVENT_MODEL" 554 "PERL_ANYEVENT_MODEL"
446 This can be used to specify the event model to be used by AnyEvent, 555 This can be used to specify the event model to be used by AnyEvent,
456 could start your program like this: 565 could start your program like this:
457 566
458 PERL_ANYEVENT_MODEL=Perl perl ... 567 PERL_ANYEVENT_MODEL=Perl perl ...
459 568
460EXAMPLE PROGRAM 569EXAMPLE PROGRAM
461 The following program uses an IO watcher to read data from STDIN, a 570 The following program uses an I/O watcher to read data from STDIN, a
462 timer to display a message once per second, and a condition variable to 571 timer to display a message once per second, and a condition variable to
463 quit the program when the user enters quit: 572 quit the program when the user enters quit:
464 573
465 use AnyEvent; 574 use AnyEvent;
466 575
609 $quit->broadcast; 718 $quit->broadcast;
610 }); 719 });
611 720
612 $quit->wait; 721 $quit->wait;
613 722
723BENCHMARKS
724 To give you an idea of the performance and overheads that AnyEvent adds
725 over the event loops themselves and to give you an impression of the
726 speed of various event loops I prepared some benchmarks.
727
728 BENCHMARKING ANYEVENT OVERHEAD
729 Here is a benchmark of various supported event models used natively and
730 through anyevent. The benchmark creates a lot of timers (with a zero
731 timeout) and I/O watchers (watching STDOUT, a pty, to become writable,
732 which it is), lets them fire exactly once and destroys them again.
733
734 Source code for this benchmark is found as eg/bench in the AnyEvent
735 distribution.
736
737 Explanation of the columns
738 *watcher* is the number of event watchers created/destroyed. Since
739 different event models feature vastly different performances, each event
740 loop was given a number of watchers so that overall runtime is
741 acceptable and similar between tested event loop (and keep them from
742 crashing): Glib would probably take thousands of years if asked to
743 process the same number of watchers as EV in this benchmark.
744
745 *bytes* is the number of bytes (as measured by the resident set size,
746 RSS) consumed by each watcher. This method of measuring captures both C
747 and Perl-based overheads.
748
749 *create* is the time, in microseconds (millionths of seconds), that it
750 takes to create a single watcher. The callback is a closure shared
751 between all watchers, to avoid adding memory overhead. That means
752 closure creation and memory usage is not included in the figures.
753
754 *invoke* is the time, in microseconds, used to invoke a simple callback.
755 The callback simply counts down a Perl variable and after it was invoked
756 "watcher" times, it would "->broadcast" a condvar once to signal the end
757 of this phase.
758
759 *destroy* is the time, in microseconds, that it takes to destroy a
760 single watcher.
761
762 Results
763 name watchers bytes create invoke destroy comment
764 EV/EV 400000 244 0.56 0.46 0.31 EV native interface
765 EV/Any 100000 244 2.50 0.46 0.29 EV + AnyEvent watchers
766 CoroEV/Any 100000 244 2.49 0.44 0.29 coroutines + Coro::Signal
767 Perl/Any 100000 513 4.92 0.87 1.12 pure perl implementation
768 Event/Event 16000 516 31.88 31.30 0.85 Event native interface
769 Event/Any 16000 590 35.75 31.42 1.08 Event + AnyEvent watchers
770 Glib/Any 16000 1357 98.22 12.41 54.00 quadratic behaviour
771 Tk/Any 2000 1860 26.97 67.98 14.00 SEGV with >> 2000 watchers
772 POE/Event 2000 6644 108.64 736.02 14.73 via POE::Loop::Event
773 POE/Select 2000 6343 94.13 809.12 565.96 via POE::Loop::Select
774
775 Discussion
776 The benchmark does *not* measure scalability of the event loop very
777 well. For example, a select-based event loop (such as the pure perl one)
778 can never compete with an event loop that uses epoll when the number of
779 file descriptors grows high. In this benchmark, all events become ready
780 at the same time, so select/poll-based implementations get an unnatural
781 speed boost.
782
783 Also, note that the number of watchers usually has a nonlinear effect on
784 overall speed, that is, creating twice as many watchers doesn't take
785 twice the time - usually it takes longer. This puts event loops tested
786 with a higher number of watchers at a disadvantage.
787
788 To put the range of results into perspective, consider that on the
789 benchmark machine, handling an event takes roughly 1600 CPU cycles with
790 EV, 3100 CPU cycles with AnyEvent's pure perl loop and almost 3000000
791 CPU cycles with POE.
792
793 "EV" is the sole leader regarding speed and memory use, which are both
794 maximal/minimal, respectively. Even when going through AnyEvent, it uses
795 far less memory than any other event loop and is still faster than Event
796 natively.
797
798 The pure perl implementation is hit in a few sweet spots (both the
799 constant timeout and the use of a single fd hit optimisations in the
800 perl interpreter and the backend itself). Nevertheless this shows that
801 it adds very little overhead in itself. Like any select-based backend
802 its performance becomes really bad with lots of file descriptors (and
803 few of them active), of course, but this was not subject of this
804 benchmark.
805
806 The "Event" module has a relatively high setup and callback invocation
807 cost, but overall scores in on the third place.
808
809 "Glib"'s memory usage is quite a bit higher, but it features a faster
810 callback invocation and overall ends up in the same class as "Event".
811 However, Glib scales extremely badly, doubling the number of watchers
812 increases the processing time by more than a factor of four, making it
813 completely unusable when using larger numbers of watchers (note that
814 only a single file descriptor was used in the benchmark, so
815 inefficiencies of "poll" do not account for this).
816
817 The "Tk" adaptor works relatively well. The fact that it crashes with
818 more than 2000 watchers is a big setback, however, as correctness takes
819 precedence over speed. Nevertheless, its performance is surprising, as
820 the file descriptor is dup()ed for each watcher. This shows that the
821 dup() employed by some adaptors is not a big performance issue (it does
822 incur a hidden memory cost inside the kernel which is not reflected in
823 the figures above).
824
825 "POE", regardless of underlying event loop (whether using its pure perl
826 select-based backend or the Event module, the POE-EV backend couldn't be
827 tested because it wasn't working) shows abysmal performance and memory
828 usage: Watchers use almost 30 times as much memory as EV watchers, and
829 10 times as much memory as Event (the high memory requirements are
830 caused by requiring a session for each watcher). Watcher invocation
831 speed is almost 900 times slower than with AnyEvent's pure perl
832 implementation. The design of the POE adaptor class in AnyEvent can not
833 really account for this, as session creation overhead is small compared
834 to execution of the state machine, which is coded pretty optimally
835 within AnyEvent::Impl::POE. POE simply seems to be abysmally slow.
836
837 Summary
838 * Using EV through AnyEvent is faster than any other event loop (even
839 when used without AnyEvent), but most event loops have acceptable
840 performance with or without AnyEvent.
841
842 * The overhead AnyEvent adds is usually much smaller than the overhead
843 of the actual event loop, only with extremely fast event loops such
844 as EV adds AnyEvent significant overhead.
845
846 * You should avoid POE like the plague if you want performance or
847 reasonable memory usage.
848
849 BENCHMARKING THE LARGE SERVER CASE
850 This benchmark atcually benchmarks the event loop itself. It works by
851 creating a number of "servers": each server consists of a socketpair, a
852 timeout watcher that gets reset on activity (but never fires), and an
853 I/O watcher waiting for input on one side of the socket. Each time the
854 socket watcher reads a byte it will write that byte to a random other
855 "server".
856
857 The effect is that there will be a lot of I/O watchers, only part of
858 which are active at any one point (so there is a constant number of
859 active fds for each loop iterstaion, but which fds these are is random).
860 The timeout is reset each time something is read because that reflects
861 how most timeouts work (and puts extra pressure on the event loops).
862
863 In this benchmark, we use 10000 socketpairs (20000 sockets), of which
864 100 (1%) are active. This mirrors the activity of large servers with
865 many connections, most of which are idle at any one point in time.
866
867 Source code for this benchmark is found as eg/bench2 in the AnyEvent
868 distribution.
869
870 Explanation of the columns
871 *sockets* is the number of sockets, and twice the number of "servers"
872 (as each server has a read and write socket end).
873
874 *create* is the time it takes to create a socketpair (which is
875 nontrivial) and two watchers: an I/O watcher and a timeout watcher.
876
877 *request*, the most important value, is the time it takes to handle a
878 single "request", that is, reading the token from the pipe and
879 forwarding it to another server. This includes deleting the old timeout
880 and creating a new one that moves the timeout into the future.
881
882 Results
883 name sockets create request
884 EV 20000 69.01 11.16
885 Perl 20000 73.32 35.87
886 Event 20000 212.62 257.32
887 Glib 20000 651.16 1896.30
888 POE 20000 349.67 12317.24 uses POE::Loop::Event
889
890 Discussion
891 This benchmark *does* measure scalability and overall performance of the
892 particular event loop.
893
894 EV is again fastest. Since it is using epoll on my system, the setup
895 time is relatively high, though.
896
897 Perl surprisingly comes second. It is much faster than the C-based event
898 loops Event and Glib.
899
900 Event suffers from high setup time as well (look at its code and you
901 will understand why). Callback invocation also has a high overhead
902 compared to the "$_->() for .."-style loop that the Perl event loop
903 uses. Event uses select or poll in basically all documented
904 configurations.
905
906 Glib is hit hard by its quadratic behaviour w.r.t. many watchers. It
907 clearly fails to perform with many filehandles or in busy servers.
908
909 POE is still completely out of the picture, taking over 1000 times as
910 long as EV, and over 100 times as long as the Perl implementation, even
911 though it uses a C-based event loop in this case.
912
913 Summary
914 * The pure perl implementation performs extremely well, considering
915 that it uses select.
916
917 * Avoid Glib or POE in large projects where performance matters.
918
919 BENCHMARKING SMALL SERVERS
920 While event loops should scale (and select-based ones do not...) even to
921 large servers, most programs we (or I :) actually write have only a few
922 I/O watchers.
923
924 In this benchmark, I use the same benchmark program as in the large
925 server case, but it uses only eight "servers", of which three are active
926 at any one time. This should reflect performance for a small server
927 relatively well.
928
929 The columns are identical to the previous table.
930
931 Results
932 name sockets create request
933 EV 16 20.00 6.54
934 Perl 16 25.75 12.62
935 Event 16 81.27 35.86
936 Glib 16 32.63 15.48
937 POE 16 261.87 276.28 uses POE::Loop::Event
938
939 Discussion
940 The benchmark tries to test the performance of a typical small server.
941 While knowing how various event loops perform is interesting, keep in
942 mind that their overhead in this case is usually not as important, due
943 to the small absolute number of watchers (that is, you need efficiency
944 and speed most when you have lots of watchers, not when you only have a
945 few of them).
946
947 EV is again fastest.
948
949 Perl again comes second. It is noticably faster than the C-based event
950 loops Event and Glib, although the difference is too small to really
951 matter.
952
953 POE also performs much better in this case, but is is still far behind
954 the others.
955
956 Summary
957 * C-based event loops perform very well with small number of watchers,
958 as the management overhead dominates.
959
614FORK 960FORK
615 Most event libraries are not fork-safe. The ones who are usually are 961 Most event libraries are not fork-safe. The ones who are usually are
616 because they are so inefficient. Only EV is fully fork-aware. 962 because they are so inefficient. Only EV is fully fork-aware.
617 963
618 If you have to fork, you must either do so *before* creating your first 964 If you have to fork, you must either do so *before* creating your first
633 979
634 use AnyEvent; 980 use AnyEvent;
635 981
636SEE ALSO 982SEE ALSO
637 Event modules: Coro::EV, EV, EV::Glib, Glib::EV, Coro::Event, Event, 983 Event modules: Coro::EV, EV, EV::Glib, Glib::EV, Coro::Event, Event,
638 Glib::Event, Glib, Coro, Tk, Event::Lib, Qt. 984 Glib::Event, Glib, Coro, Tk, Event::Lib, Qt, POE.
639 985
640 Implementations: AnyEvent::Impl::CoroEV, AnyEvent::Impl::EV, 986 Implementations: AnyEvent::Impl::CoroEV, AnyEvent::Impl::EV,
641 AnyEvent::Impl::CoroEvent, AnyEvent::Impl::Event, AnyEvent::Impl::Glib, 987 AnyEvent::Impl::CoroEvent, AnyEvent::Impl::Event, AnyEvent::Impl::Glib,
642 AnyEvent::Impl::Tk, AnyEvent::Impl::Perl, AnyEvent::Impl::EventLib, 988 AnyEvent::Impl::Tk, AnyEvent::Impl::Perl, AnyEvent::Impl::EventLib,
643 AnyEvent::Impl::Qt. 989 AnyEvent::Impl::Qt, AnyEvent::Impl::POE.
644 990
645 Nontrivial usage examples: Net::FCP, Net::XMPP2. 991 Nontrivial usage examples: Net::FCP, Net::XMPP2.
646 992
647AUTHOR 993AUTHOR
648 Marc Lehmann <schmorp@schmorp.de> 994 Marc Lehmann <schmorp@schmorp.de>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines