--- AnyEvent/lib/AnyEvent.pm 2008/04/23 11:25:42 1.55 +++ AnyEvent/lib/AnyEvent.pm 2008/04/24 08:38:13 1.59 @@ -2,7 +2,7 @@ AnyEvent - provide framework for multiple event loops -EV, Event, Coro::EV, Coro::Event, Glib, Tk, Perl, Event::Lib - various supported event loops +EV, Event, Coro::EV, Coro::Event, Glib, Tk, Perl, Event::Lib, Qt - various supported event loops =head1 SYNOPSIS @@ -80,13 +80,14 @@ module. During the first call of any watcher-creation method, the module tries -to detect the currently loaded event loop by probing whether one of the -following modules is already loaded: L, L, L, -L, L, L. The first one found is used. If none are found, -the module tries to load these modules in the stated order. The first one -that can be successfully loaded will be used. If, after this, still none -could be found, AnyEvent will fall back to a pure-perl event loop, which -is not very efficient, but should work everywhere. +to detect the currently loaded event loop by probing whether one of +the following modules is already loaded: L, L, +L, L, L, L, L, L. The first one +found is used. If none are found, the module tries to load these modules +(excluding Event::Lib and Qt) in the order given. The first one that can +be successfully loaded will be used. If, after this, still none could be +found, AnyEvent will fall back to a pure-perl event loop, which is not +very efficient, but should work everywhere. Because AnyEvent first checks for modules that are already loaded, loading an event model explicitly before first using AnyEvent will likely make @@ -147,8 +148,8 @@ respectively. C is the callback to invoke each time the file handle becomes ready. -File handles will be kept alive, so as long as the watcher exists, the -file handle exists, too. +As long as the I/O watcher exists it will keep the file descriptor or a +copy of it alive/open. It is not allowed to close a file handle as long as any watcher is active on the underlying file descriptor. @@ -208,15 +209,16 @@ in 10 seconds") and based on wallclock time (absolute, "fire at 12 o'clock"). -While most event loops expect timers to specified in a relative way, they use -absolute time internally. This makes a difference when your clock "jumps", -for example, when ntp decides to set your clock backwards from the wrong 2014-01-01 to -2008-01-01, a watcher that you created to fire "after" a second might actually take -six years to finally fire. +While most event loops expect timers to specified in a relative way, they +use absolute time internally. This makes a difference when your clock +"jumps", for example, when ntp decides to set your clock backwards from +the wrong date of 2014-01-01 to 2008-01-01, a watcher that is supposed to +fire "after" a second might actually take six years to finally fire. AnyEvent cannot compensate for this. The only event loop that is conscious -about these issues is L, which offers both relative (ev_timer) and -absolute (ev_periodic) timers. +about these issues is L, which offers both relative (ev_timer, based +on true relative time) and absolute (ev_periodic, based on wallclock time) +timers. AnyEvent always prefers relative timers, if available, matching the AnyEvent API. @@ -227,7 +229,7 @@ I without any C prefix, C is the Perl callback to be invoked whenever a signal occurs. -Multiple signals occurances can be clumped together into one callback +Multiple signal occurances can be clumped together into one callback invocation, and callback invocation will be synchronous. synchronous means that it might take a while until the signal gets handled by the process, but it is guarenteed not to interrupt any other callbacks. @@ -355,11 +357,12 @@ AnyEvent::Impl::CoroEV based on Coro::EV, best choice. AnyEvent::Impl::CoroEvent based on Coro::Event, second best choice. - AnyEvent::Impl::EV based on EV (an interface to libev, also best choice). - AnyEvent::Impl::Event based on Event, also second best choice :) + AnyEvent::Impl::EV based on EV (an interface to libev, best choice). + AnyEvent::Impl::Event based on Event, second best choice. AnyEvent::Impl::Glib based on Glib, third-best choice. AnyEvent::Impl::Tk based on Tk, very bad choice. AnyEvent::Impl::Perl pure-perl implementation, inefficient but portable. + AnyEvent::Impl::Qt based on Qt, cannot be autoprobed (see its docs). AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. =item AnyEvent::detect @@ -421,7 +424,7 @@ use Carp; -our $VERSION = '3.12'; +our $VERSION = '3.2'; our $MODEL; our $AUTOLOAD; @@ -439,10 +442,13 @@ [Glib:: => AnyEvent::Impl::Glib::], [Tk:: => AnyEvent::Impl::Tk::], [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], - [Event::Lib:: => AnyEvent::Impl::EventLib::], +); +my @models_detect = ( + [Qt:: => AnyEvent::Impl::Qt::], # requires special main program + [Event::Lib:: => AnyEvent::Impl::EventLib::], # too buggy ); -our %method = map +($_ => 1), qw(io timer condvar broadcast wait signal one_event DESTROY); +our %method = map +($_ => 1), qw(io timer signal child condvar broadcast wait one_event DESTROY); sub detect() { unless ($MODEL) { @@ -458,7 +464,7 @@ # check for already loaded models unless ($MODEL) { - for (@REGISTRY, @models) { + for (@REGISTRY, @models, @models_detect) { my ($package, $model) = @$_; if (${"$package\::VERSION"} > 0) { if (eval "require $model") { @@ -860,11 +866,12 @@ Event modules: L, L, L, L, L, L, L, L, L, L, -L. +L, L. Implementations: L, L, L, L, L, -L, L, L. +L, L, L, +L. Nontrivial usage examples: L, L.