--- EV/README 2007/12/22 12:05:42 1.20 +++ EV/README 2007/12/22 16:48:33 1.21 @@ -74,7 +74,7 @@ default loop as this is fastest (perl-wise), best supported by other modules (e.g. AnyEvent or Coro) and most portable event loop. - For specific programs you cna create additional event loops dynamically. + For specific programs you can create additional event loops dynamically. $loop = new EV::loop [$flags] Create a new event loop as per the specified flags. Please refer to @@ -94,6 +94,9 @@ "EV::FLAG_FORKCHECK" which calls this fucntion automatically, at some performance loss (refer to the libev documentation). + $loop = EV::default_loop [$flags] + Return the default loop (which is a singleton object). + BASIC INTERFACE $EV::DIED Must contain a reference to a function that is called when a @@ -102,6 +105,17 @@ If this callback throws an exception it will be silently ignored. + $flags = EV::supported_backends + $flags = EV::recommended_backends + $flags = EV::embeddable_backends + Returns the set (see "EV::BACKEND_*" flags) of backends supported by + this instance of EV, the set of recommended backends (supposed to be + good) for this platform and the set of embeddable backends (see + EMBED WATCHERS). + + EV::sleep $seconds + Block the process for the given number of (fractional) seconds. + $time = EV::time Returns the current time in (fractional) seconds since the epoch. @@ -174,6 +188,16 @@ Feed a signal event into EV. EV will react to this call as if the signal specified by $signal had occured. + EV::set_io_collect_interval $time + $loop->set_io_collect_interval ($time) + EV::set_timeout_collect_interval $time + $loop->set_timeout_collect_interval ($time) + These advanced functions set the minimum block interval when polling + for I/O events and the minimum wait interval for timer events. See + the libev documentation at + for a more detailed discussion. + WATCHER OBJECTS A watcher is an object that gets created to record your interest in some event. For instance, if you want to wait for STDIN to become readable, @@ -710,6 +734,45 @@ The "fork_ns" variant doesn't start (activate) the newly created watcher. + EMBED WATCHERS - when one backend isn't enough... + This is a rather advanced watcher type that lets you embed one event + loop into another (currently only IO events are supported in the + embedded loop, other types of watchers might be handled in a delayed or + incorrect fashion and must not be used). + + See the libev documentation at + for more details. + + In short, this watcher is most useful on BSD systems without working + kqueue to still be able to handle a large number of sockets: + + my $socket_loop; + + # check wether we use SELECT or POLL _and_ KQUEUE is supported + if ( + (EV::backend & (EV::BACKEND_POLL | EV::BACKEND_SELECT)) + && (EV::supported_backends & EV::embeddable_backends & EV::BACKEND_KQUEUE) + ) { + # use kqueue for sockets + $socket_loop = new EV::Loop EV::BACKEND_KQUEUE | EV::FLAG_NOENV; + } + + # use the default loop otherwise + $socket_loop ||= EV::default_loop; + + $w = EV::embed $otherloop, $callback + $w = EV::embed_ns $otherloop, $callback + $w = $loop->embed ($otherloop, $callback) + $w = $loop->embed_ns ($otherloop, $callback) + Call the callback when the embedded event loop ($otherloop) has any + I/O activity. The $callback should alwas be specified as "undef" in + this version of EV, which means the embedded event loop will be + managed automatically. + + The "embed_ns" variant doesn't start (activate) the newly created + watcher. + PERL SIGNALS While Perl signal handling (%SIG) is not affected by EV, the behaviour with EV is as the same as any other C library: Perl-signals will only be