… | |
… | |
806 | =over 4 |
806 | =over 4 |
807 | |
807 | |
808 | =item Backends that are autoprobed when no other event loop can be found. |
808 | =item Backends that are autoprobed when no other event loop can be found. |
809 | |
809 | |
810 | EV is the preferred backend when no other event loop seems to be in |
810 | EV is the preferred backend when no other event loop seems to be in |
811 | use. If EV is not installed, then AnyEvent will try Event, and, failing |
811 | use. If EV is not installed, then AnyEvent will fall back to its own |
812 | that, will fall back to its own pure-perl implementation, which is |
812 | pure-perl implementation, which is available everywhere as it comes with |
813 | available everywhere as it comes with AnyEvent itself. |
813 | AnyEvent itself. |
814 | |
814 | |
815 | AnyEvent::Impl::EV based on EV (interface to libev, best choice). |
815 | AnyEvent::Impl::EV based on EV (interface to libev, best choice). |
816 | AnyEvent::Impl::Event based on Event, very stable, few glitches. |
|
|
817 | AnyEvent::Impl::Perl pure-perl implementation, fast and portable. |
816 | AnyEvent::Impl::Perl pure-perl implementation, fast and portable. |
818 | |
817 | |
819 | =item Backends that are transparently being picked up when they are used. |
818 | =item Backends that are transparently being picked up when they are used. |
820 | |
819 | |
821 | These will be used when they are currently loaded when the first watcher |
820 | These will be used when they are currently loaded when the first watcher |
822 | is created, in which case it is assumed that the application is using |
821 | is created, in which case it is assumed that the application is using |
823 | them. This means that AnyEvent will automatically pick the right backend |
822 | them. This means that AnyEvent will automatically pick the right backend |
824 | when the main program loads an event module before anything starts to |
823 | when the main program loads an event module before anything starts to |
825 | create watchers. Nothing special needs to be done by the main program. |
824 | create watchers. Nothing special needs to be done by the main program. |
826 | |
825 | |
|
|
826 | AnyEvent::Impl::Event based on Event, very stable, few glitches. |
827 | AnyEvent::Impl::Glib based on Glib, slow but very stable. |
827 | AnyEvent::Impl::Glib based on Glib, slow but very stable. |
828 | AnyEvent::Impl::Tk based on Tk, very broken. |
828 | AnyEvent::Impl::Tk based on Tk, very broken. |
829 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
829 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
830 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
830 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
831 | AnyEvent::Impl::Irssi used when running within irssi. |
831 | AnyEvent::Impl::Irssi used when running within irssi. |
… | |
… | |
1151 | $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
1151 | $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
1152 | } |
1152 | } |
1153 | |
1153 | |
1154 | my @models = ( |
1154 | my @models = ( |
1155 | [EV:: => AnyEvent::Impl::EV:: , 1], |
1155 | [EV:: => AnyEvent::Impl::EV:: , 1], |
1156 | [Event:: => AnyEvent::Impl::Event::, 1], |
|
|
1157 | [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl:: , 1], |
1156 | [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl:: , 1], |
1158 | # everything below here will not (normally) be autoprobed |
1157 | # everything below here will not (normally) be autoprobed |
1159 | # as the pureperl backend should work everywhere |
1158 | # as the pureperl backend should work everywhere |
1160 | # and is usually faster |
1159 | # and is usually faster |
|
|
1160 | [Event:: => AnyEvent::Impl::Event::, 1], |
1161 | [Glib:: => AnyEvent::Impl::Glib:: , 1], # becomes extremely slow with many watchers |
1161 | [Glib:: => AnyEvent::Impl::Glib:: , 1], # becomes extremely slow with many watchers |
1162 | [Event::Lib:: => AnyEvent::Impl::EventLib::], # too buggy |
1162 | [Event::Lib:: => AnyEvent::Impl::EventLib::], # too buggy |
1163 | [Irssi:: => AnyEvent::Impl::Irssi::], # Irssi has a bogus "Event" package |
1163 | [Irssi:: => AnyEvent::Impl::Irssi::], # Irssi has a bogus "Event" package |
1164 | [Tk:: => AnyEvent::Impl::Tk::], # crashes with many handles |
1164 | [Tk:: => AnyEvent::Impl::Tk::], # crashes with many handles |
1165 | [Qt:: => AnyEvent::Impl::Qt::], # requires special main program |
1165 | [Qt:: => AnyEvent::Impl::Qt::], # requires special main program |
… | |
… | |
1168 | [Prima:: => AnyEvent::Impl::POE::], |
1168 | [Prima:: => AnyEvent::Impl::POE::], |
1169 | # IO::Async is just too broken - we would need workarounds for its |
1169 | # IO::Async is just too broken - we would need workarounds for its |
1170 | # byzantine signal and broken child handling, among others. |
1170 | # byzantine signal and broken child handling, among others. |
1171 | # IO::Async is rather hard to detect, as it doesn't have any |
1171 | # IO::Async is rather hard to detect, as it doesn't have any |
1172 | # obvious default class. |
1172 | # obvious default class. |
1173 | # [0, IO::Async:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1173 | [IO::Async:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1174 | # [0, IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1174 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1175 | # [0, IO::Async::Notifier:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1175 | [IO::Async::Notifier:: => AnyEvent::Impl::IOAsync::], # requires special main program |
|
|
1176 | [AnyEvent::Impl::IOAsync:: => AnyEvent::Impl::IOAsync::], # requires special main program |
1176 | ); |
1177 | ); |
1177 | |
1178 | |
1178 | our %method = map +($_ => 1), |
1179 | our %method = map +($_ => 1), |
1179 | qw(io timer time now now_update signal child idle condvar one_event DESTROY); |
1180 | qw(io timer time now now_update signal child idle condvar one_event DESTROY); |
1180 | |
1181 | |
… | |
… | |
1293 | # "new" API, currently only emulation of it |
1294 | # "new" API, currently only emulation of it |
1294 | ############################################################################# |
1295 | ############################################################################# |
1295 | |
1296 | |
1296 | package AE; |
1297 | package AE; |
1297 | |
1298 | |
|
|
1299 | our $VERSION = $AnyEvent::VERSION; |
|
|
1300 | |
1298 | sub io($$$) { |
1301 | sub io($$$) { |
1299 | AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2]) |
1302 | AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2]) |
1300 | } |
1303 | } |
1301 | |
1304 | |
1302 | sub timer($$$) { |
1305 | sub timer($$$) { |
1303 | AnyEvent->timer (after => $_[0], interval => $_[1], cb => $_[2]); |
1306 | AnyEvent->timer (after => $_[0], interval => $_[1], cb => $_[2]) |
1304 | } |
1307 | } |
1305 | |
1308 | |
1306 | sub signal($$) { |
1309 | sub signal($$) { |
1307 | AnyEvent->signal (signal => $_[0], cb => $_[1]); |
1310 | AnyEvent->signal (signal => $_[0], cb => $_[1]) |
1308 | } |
1311 | } |
1309 | |
1312 | |
1310 | sub child($$) { |
1313 | sub child($$) { |
1311 | AnyEvent->child (pid => $_[0], cb => $_[1]); |
1314 | AnyEvent->child (pid => $_[0], cb => $_[1]) |
1312 | } |
1315 | } |
1313 | |
1316 | |
1314 | sub idle($) { |
1317 | sub idle($) { |
1315 | AnyEvent->idle (cb => $_[0]); |
1318 | AnyEvent->idle (cb => $_[0]) |
1316 | } |
1319 | } |
1317 | |
1320 | |
1318 | sub cv(;&) { |
1321 | sub cv(;&) { |
1319 | AnyEvent->condvar (@_ ? (cb => $_[0]) : ()) |
1322 | AnyEvent->condvar (@_ ? (cb => $_[0]) : ()) |
1320 | } |
1323 | } |