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

Comparing EV/README (file contents):
Revision 1.22 by root, Mon Jan 28 12:24:05 2008 UTC vs.
Revision 1.27 by root, Mon May 26 05:37:18 2008 UTC

54 54
55DESCRIPTION 55DESCRIPTION
56 This module provides an interface to libev 56 This module provides an interface to libev
57 (<http://software.schmorp.de/pkg/libev.html>). While the documentation 57 (<http://software.schmorp.de/pkg/libev.html>). While the documentation
58 below is comprehensive, one might also consult the documentation of 58 below is comprehensive, one might also consult the documentation of
59 libev itself (<http://cvs.schmorp.de/libev/ev.html>) for more subtle 59 libev itself (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod>)
60 details on watcher semantics or some discussion on the available 60 for more subtle details on watcher semantics or some discussion on the
61 backends, or how to force a specific backend with "LIBEV_FLAGS", or just 61 available backends, or how to force a specific backend with
62 about in any case because it has much more detailed information. 62 "LIBEV_FLAGS", or just about in any case because it has much more
63 detailed information.
64
65 This module is very fast and scalable. It is actually so fast that you
66 can use it through the AnyEvent module, stay portable to other event
67 loops (if you don't rely on any watcher types not available through it)
68 and still be faster than with any other event loop currently supported
69 in Perl.
63 70
64EVENT LOOPS 71EVENT LOOPS
65 EV supports multiple event loops: There is a single "default event loop" 72 EV supports multiple event loops: There is a single "default event loop"
66 that can handle everything including signals and child watchers, and any 73 that can handle everything including signals and child watchers, and any
67 number of "dynamic event loops" that can use different backends (with 74 number of "dynamic event loops" that can use different backends (with
89 loop is protected by this module. 96 loop is protected by this module.
90 97
91 $loop->loop_fork 98 $loop->loop_fork
92 Must be called after a fork in the child, before entering or 99 Must be called after a fork in the child, before entering or
93 continuing the event loop. An alternative is to use 100 continuing the event loop. An alternative is to use
94 "EV::FLAG_FORKCHECK" which calls this fucntion automatically, at 101 "EV::FLAG_FORKCHECK" which calls this function automatically, at
95 some performance loss (refer to the libev documentation). 102 some performance loss (refer to the libev documentation).
96 103
104 $loop->loop_verify
105 Calls "ev_verify" to make internal consistency checks (for debugging
106 libev) and abort the program if any data structures wree found to be
107 corrupted.
108
97 $loop = EV::default_loop [$flags] 109 $loop = EV::default_loop [$flags]
98 Return the default loop (which is a singleton object). 110 Return the default loop (which is a singleton object). Since this
111 module already creates the default loop with default flags,
112 specifying flags here will not have any effect unless you destroy
113 the default loop.
99 114
100BASIC INTERFACE 115BASIC INTERFACE
101 $EV::DIED 116 $EV::DIED
102 Must contain a reference to a function that is called when a 117 Must contain a reference to a function that is called when a
103 callback throws an exception (with $@ containing the error). The 118 callback throws an exception (with $@ containing the error). The
421 This time simply fires at the wallclock time $at and doesn't 436 This time simply fires at the wallclock time $at and doesn't
422 repeat. It will not adjust when a time jump occurs, that is, if 437 repeat. It will not adjust when a time jump occurs, that is, if
423 it is to be run at January 1st 2011 then it will run when the 438 it is to be run at January 1st 2011 then it will run when the
424 system time reaches or surpasses this time. 439 system time reaches or surpasses this time.
425 440
426 * non-repeating interval timer ($interval > 0, $reschedule_cb = 0) 441 * repeating interval timer ($interval > 0, $reschedule_cb = 0)
427 442
428 In this mode the watcher will always be scheduled to time out at 443 In this mode the watcher will always be scheduled to time out at
429 the next "$at + N * $interval" time (for some integer N) and 444 the next "$at + N * $interval" time (for some integer N) and
430 then repeat, regardless of any time jumps. 445 then repeat, regardless of any time jumps.
431 446
449 each time the periodic watcher gets scheduled, the reschedule 464 each time the periodic watcher gets scheduled, the reschedule
450 callback ($reschedule_cb) will be called with the watcher as 465 callback ($reschedule_cb) will be called with the watcher as
451 first, and the current time as second argument. 466 first, and the current time as second argument.
452 467
453 *This callback MUST NOT stop or destroy this or any other 468 *This callback MUST NOT stop or destroy this or any other
469 periodic watcher, ever, and MUST NOT call any event loop
454 periodic watcher, ever*. If you need to stop it, return 1e30 and 470 functions or methods*. If you need to stop it, return 1e30 and
455 stop it afterwards. 471 stop it afterwards. You may create and start a "EV::prepare"
472 watcher for this task.
456 473
457 It must return the next time to trigger, based on the passed 474 It must return the next time to trigger, based on the passed
458 time value (that is, the lowest time value larger than to the 475 time value (that is, the lowest time value larger than or equal
459 second argument). It will usually be called just before the 476 to to the second argument). It will usually be called just
460 callback will be triggered, but might be called at other times, 477 before the callback will be triggered, but might be called at
461 too. 478 other times, too.
462 479
463 This can be used to create very complex timers, such as a timer 480 This can be used to create very complex timers, such as a timer
464 that triggers on each midnight, local time (actually 24 hours 481 that triggers on each midnight, local time (actually 24 hours
465 after the last midnight, to keep the example simple. If you know 482 after the last midnight, to keep the example simple. If you know
466 a way to do it correctly in about the same space (without 483 a way to do it correctly in about the same space (without
776 managed automatically. 793 managed automatically.
777 794
778 The "embed_ns" variant doesn't start (activate) the newly created 795 The "embed_ns" variant doesn't start (activate) the newly created
779 watcher. 796 watcher.
780 797
798 ASYNC WATCHERS - how to wake up another event loop
799 Async watchers are provided by EV, but have little use in perl directly,
800 as perl neither supports threads nor direct access to signal handlers or
801 other contexts where they could be of value.
802
803 It is, however, possible to use them from the XS level.
804
805 Please see the libev documentation for further details.
806
807 $w = EV::async $callback
808 $w = EV::async_ns $callback
809 $w->send
810 $bool = $w->async_pending
811
781PERL SIGNALS 812PERL SIGNALS
782 While Perl signal handling (%SIG) is not affected by EV, the behaviour 813 While Perl signal handling (%SIG) is not affected by EV, the behaviour
783 with EV is as the same as any other C library: Perl-signals will only be 814 with EV is as the same as any other C library: Perl-signals will only be
784 handled when Perl runs, which means your signal handler might be invoked 815 handled when Perl runs, which means your signal handler might be invoked
785 only the next time an event callback is invoked. 816 only the next time an event callback is invoked.
819 course. 850 course.
820 851
821SEE ALSO 852SEE ALSO
822 EV::ADNS (asynchronous DNS), Glib::EV (makes Glib/Gtk2 use EV as event 853 EV::ADNS (asynchronous DNS), Glib::EV (makes Glib/Gtk2 use EV as event
823 loop), EV::Glib (embed Glib into EV), Coro::EV (efficient coroutines 854 loop), EV::Glib (embed Glib into EV), Coro::EV (efficient coroutines
824 with EV), Net::SNMP::EV (asynchronous SNMP). 855 with EV), Net::SNMP::EV (asynchronous SNMP), AnyEvent for event-loop
856 agnostic and portable event driven programming.
825 857
826AUTHOR 858AUTHOR
827 Marc Lehmann <schmorp@schmorp.de> 859 Marc Lehmann <schmorp@schmorp.de>
828 http://home.schmorp.de/ 860 http://home.schmorp.de/
829 861

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines