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

Comparing EV/README (file contents):
Revision 1.20 by root, Sat Dec 22 12:05:42 2007 UTC vs.
Revision 1.21 by root, Sat Dec 22 16:48:33 2007 UTC

72 selecting a working backend (which for example rules out kqueue on most 72 selecting a working backend (which for example rules out kqueue on most
73 BSDs). Modules should, unless they have "special needs" always use the 73 BSDs). Modules should, unless they have "special needs" always use the
74 default loop as this is fastest (perl-wise), best supported by other 74 default loop as this is fastest (perl-wise), best supported by other
75 modules (e.g. AnyEvent or Coro) and most portable event loop. 75 modules (e.g. AnyEvent or Coro) and most portable event loop.
76 76
77 For specific programs you cna create additional event loops dynamically. 77 For specific programs you can create additional event loops dynamically.
78 78
79 $loop = new EV::loop [$flags] 79 $loop = new EV::loop [$flags]
80 Create a new event loop as per the specified flags. Please refer to 80 Create a new event loop as per the specified flags. Please refer to
81 the "ev_loop_new ()" function description in the libev documentation 81 the "ev_loop_new ()" function description in the libev documentation
82 (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#GLOBAL_FUNCTI 82 (<http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#GLOBAL_FUNCTI
92 Must be called after a fork in the child, before entering or 92 Must be called after a fork in the child, before entering or
93 continuing the event loop. An alternative is to use 93 continuing the event loop. An alternative is to use
94 "EV::FLAG_FORKCHECK" which calls this fucntion automatically, at 94 "EV::FLAG_FORKCHECK" which calls this fucntion automatically, at
95 some performance loss (refer to the libev documentation). 95 some performance loss (refer to the libev documentation).
96 96
97 $loop = EV::default_loop [$flags]
98 Return the default loop (which is a singleton object).
99
97BASIC INTERFACE 100BASIC INTERFACE
98 $EV::DIED 101 $EV::DIED
99 Must contain a reference to a function that is called when a 102 Must contain a reference to a function that is called when a
100 callback throws an exception (with $@ containing the error). The 103 callback throws an exception (with $@ containing the error). The
101 default prints an informative message and continues. 104 default prints an informative message and continues.
102 105
103 If this callback throws an exception it will be silently ignored. 106 If this callback throws an exception it will be silently ignored.
107
108 $flags = EV::supported_backends
109 $flags = EV::recommended_backends
110 $flags = EV::embeddable_backends
111 Returns the set (see "EV::BACKEND_*" flags) of backends supported by
112 this instance of EV, the set of recommended backends (supposed to be
113 good) for this platform and the set of embeddable backends (see
114 EMBED WATCHERS).
115
116 EV::sleep $seconds
117 Block the process for the given number of (fractional) seconds.
104 118
105 $time = EV::time 119 $time = EV::time
106 Returns the current time in (fractional) seconds since the epoch. 120 Returns the current time in (fractional) seconds since the epoch.
107 121
108 $time = EV::now 122 $time = EV::now
171 descriptor $fd. 185 descriptor $fd.
172 186
173 EV::feed_signal_event ($signal) 187 EV::feed_signal_event ($signal)
174 Feed a signal event into EV. EV will react to this call as if the 188 Feed a signal event into EV. EV will react to this call as if the
175 signal specified by $signal had occured. 189 signal specified by $signal had occured.
190
191 EV::set_io_collect_interval $time
192 $loop->set_io_collect_interval ($time)
193 EV::set_timeout_collect_interval $time
194 $loop->set_timeout_collect_interval ($time)
195 These advanced functions set the minimum block interval when polling
196 for I/O events and the minimum wait interval for timer events. See
197 the libev documentation at
198 <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#FUNCTIONS_CONT
199 ROLLING_THE_EVENT_LOOP> for a more detailed discussion.
176 200
177WATCHER OBJECTS 201WATCHER OBJECTS
178 A watcher is an object that gets created to record your interest in some 202 A watcher is an object that gets created to record your interest in some
179 event. For instance, if you want to wait for STDIN to become readable, 203 event. For instance, if you want to wait for STDIN to become readable,
180 you would create an EV::io watcher for that: 204 you would create an EV::io watcher for that:
708 process after a fork. 732 process after a fork.
709 733
710 The "fork_ns" variant doesn't start (activate) the newly created 734 The "fork_ns" variant doesn't start (activate) the newly created
711 watcher. 735 watcher.
712 736
737 EMBED WATCHERS - when one backend isn't enough...
738 This is a rather advanced watcher type that lets you embed one event
739 loop into another (currently only IO events are supported in the
740 embedded loop, other types of watchers might be handled in a delayed or
741 incorrect fashion and must not be used).
742
743 See the libev documentation at
744 <http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#code_ev_embed_code
745 _when_one_backend_> for more details.
746
747 In short, this watcher is most useful on BSD systems without working
748 kqueue to still be able to handle a large number of sockets:
749
750 my $socket_loop;
751
752 # check wether we use SELECT or POLL _and_ KQUEUE is supported
753 if (
754 (EV::backend & (EV::BACKEND_POLL | EV::BACKEND_SELECT))
755 && (EV::supported_backends & EV::embeddable_backends & EV::BACKEND_KQUEUE)
756 ) {
757 # use kqueue for sockets
758 $socket_loop = new EV::Loop EV::BACKEND_KQUEUE | EV::FLAG_NOENV;
759 }
760
761 # use the default loop otherwise
762 $socket_loop ||= EV::default_loop;
763
764 $w = EV::embed $otherloop, $callback
765 $w = EV::embed_ns $otherloop, $callback
766 $w = $loop->embed ($otherloop, $callback)
767 $w = $loop->embed_ns ($otherloop, $callback)
768 Call the callback when the embedded event loop ($otherloop) has any
769 I/O activity. The $callback should alwas be specified as "undef" in
770 this version of EV, which means the embedded event loop will be
771 managed automatically.
772
773 The "embed_ns" variant doesn't start (activate) the newly created
774 watcher.
775
713PERL SIGNALS 776PERL SIGNALS
714 While Perl signal handling (%SIG) is not affected by EV, the behaviour 777 While Perl signal handling (%SIG) is not affected by EV, the behaviour
715 with EV is as the same as any other C library: Perl-signals will only be 778 with EV is as the same as any other C library: Perl-signals will only be
716 handled when Perl runs, which means your signal handler might be invoked 779 handled when Perl runs, which means your signal handler might be invoked
717 only the next time an event callback is invoked. 780 only the next time an event callback is invoked.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines