… | |
… | |
878 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
878 | AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. |
879 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
879 | AnyEvent::Impl::POE based on POE, very slow, some limitations. |
880 | AnyEvent::Impl::Irssi used when running within irssi. |
880 | AnyEvent::Impl::Irssi used when running within irssi. |
881 | AnyEvent::Impl::IOAsync based on IO::Async. |
881 | AnyEvent::Impl::IOAsync based on IO::Async. |
882 | AnyEvent::Impl::Cocoa based on Cocoa::EventLoop. |
882 | AnyEvent::Impl::Cocoa based on Cocoa::EventLoop. |
883 | AnyEvent::Impl::FLTK2 based on FLTK (fltk 2 binding). |
883 | AnyEvent::Impl::FLTK based on FLTK (fltk 2 binding). |
884 | |
884 | |
885 | =item Backends with special needs. |
885 | =item Backends with special needs. |
886 | |
886 | |
887 | Qt requires the Qt::Application to be instantiated first, but will |
887 | Qt requires the Qt::Application to be instantiated first, but will |
888 | otherwise be picked up automatically. As long as the main program |
888 | otherwise be picked up automatically. As long as the main program |
… | |
… | |
1058 | If L<AnyEvent::Log> is not loaded then this function makes a simple test |
1058 | If L<AnyEvent::Log> is not loaded then this function makes a simple test |
1059 | to see whether the message will be logged. If the test succeeds it will |
1059 | to see whether the message will be logged. If the test succeeds it will |
1060 | load AnyEvent::Log and call C<AnyEvent::Log::log> - consequently, look at |
1060 | load AnyEvent::Log and call C<AnyEvent::Log::log> - consequently, look at |
1061 | the L<AnyEvent::Log> documentation for details. |
1061 | the L<AnyEvent::Log> documentation for details. |
1062 | |
1062 | |
1063 | If the test fails it will simply return. |
1063 | If the test fails it will simply return. Right now this happens when a |
|
|
1064 | numerical loglevel is used and it is larger than the level specified via |
|
|
1065 | C<$ENV{PERL_ANYEVENT_VERBOSE}>. |
1064 | |
1066 | |
1065 | If you want to sprinkle loads of logging calls around your code, consider |
1067 | If you want to sprinkle loads of logging calls around your code, consider |
1066 | creating a logger callback with the C<AnyEvent::Log::logger> function, |
1068 | creating a logger callback with the C<AnyEvent::Log::logger> function, |
1067 | which can reduce typing, codesize and can reduce the logging overhead |
1069 | which can reduce typing, codesize and can reduce the logging overhead |
1068 | enourmously. |
1070 | enourmously. |
… | |
… | |
1166 | |
1168 | |
1167 | Implement event-based interfaces to the protocols of the same name (for |
1169 | Implement event-based interfaces to the protocols of the same name (for |
1168 | the curious, IGS is the International Go Server and FCP is the Freenet |
1170 | the curious, IGS is the International Go Server and FCP is the Freenet |
1169 | Client Protocol). |
1171 | Client Protocol). |
1170 | |
1172 | |
1171 | =item L<AnyEvent::Handle::UDP> |
|
|
1172 | |
|
|
1173 | Here be danger! |
|
|
1174 | |
|
|
1175 | As Pauli would put it, "Not only is it not right, it's not even wrong!" - |
|
|
1176 | there are so many things wrong with AnyEvent::Handle::UDP, most notably |
|
|
1177 | its use of a stream-based API with a protocol that isn't streamable, that |
|
|
1178 | the only way to improve it is to delete it. |
|
|
1179 | |
|
|
1180 | It features data corruption (but typically only under load) and general |
|
|
1181 | confusion. On top, the author is not only clueless about UDP but also |
|
|
1182 | fact-resistant - some gems of his understanding: "connect doesn't work |
|
|
1183 | with UDP", "UDP packets are not IP packets", "UDP only has datagrams, not |
|
|
1184 | packets", "I don't need to implement proper error checking as UDP doesn't |
|
|
1185 | support error checking" and so on - he doesn't even understand what's |
|
|
1186 | wrong with his module when it is explained to him. |
|
|
1187 | |
|
|
1188 | =item L<AnyEvent::DBI> |
|
|
1189 | |
|
|
1190 | Executes L<DBI> requests asynchronously in a proxy process for you, |
|
|
1191 | notifying you in an event-based way when the operation is finished. |
|
|
1192 | |
|
|
1193 | =item L<AnyEvent::AIO> |
1173 | =item L<AnyEvent::AIO> |
1194 | |
1174 | |
1195 | Truly asynchronous (as opposed to non-blocking) I/O, should be in the |
1175 | Truly asynchronous (as opposed to non-blocking) I/O, should be in the |
1196 | toolbox of every event programmer. AnyEvent::AIO transparently fuses |
1176 | toolbox of every event programmer. AnyEvent::AIO transparently fuses |
1197 | L<IO::AIO> and AnyEvent together, giving AnyEvent access to event-based |
1177 | L<IO::AIO> and AnyEvent together, giving AnyEvent access to event-based |
1198 | file I/O, and much more. |
1178 | file I/O, and much more. |
1199 | |
1179 | |
|
|
1180 | =item L<AnyEvent::Filesys::Notify> |
|
|
1181 | |
|
|
1182 | AnyEvent is good for non-blocking stuff, but it can't detect file or |
|
|
1183 | path changes (e.g. "watch this directory for new files", "watch this |
|
|
1184 | file for changes"). The L<AnyEvent::Filesys::Notify> module promises to |
|
|
1185 | do just that in a portbale fashion, supporting inotify on GNU/Linux and |
|
|
1186 | some weird, without doubt broken, stuff on OS X to monitor files. It can |
|
|
1187 | fall back to blocking scans at regular intervals transparently on other |
|
|
1188 | platforms, so it's about as portable as it gets. |
|
|
1189 | |
|
|
1190 | (I haven't used it myself, but I haven't heard anybody complaining about |
|
|
1191 | it yet). |
|
|
1192 | |
|
|
1193 | =item L<AnyEvent::DBI> |
|
|
1194 | |
|
|
1195 | Executes L<DBI> requests asynchronously in a proxy process for you, |
|
|
1196 | notifying you in an event-based way when the operation is finished. |
|
|
1197 | |
1200 | =item L<AnyEvent::HTTPD> |
1198 | =item L<AnyEvent::HTTPD> |
1201 | |
1199 | |
1202 | A simple embedded webserver. |
1200 | A simple embedded webserver. |
1203 | |
1201 | |
1204 | =item L<AnyEvent::FastPing> |
1202 | =item L<AnyEvent::FastPing> |
1205 | |
1203 | |
1206 | The fastest ping in the west. |
1204 | The fastest ping in the west. |
1207 | |
1205 | |
1208 | =item L<Coro> |
1206 | =item L<Coro> |
1209 | |
1207 | |
1210 | Has special support for AnyEvent via L<Coro::AnyEvent>. |
1208 | Has special support for AnyEvent via L<Coro::AnyEvent>, which allows you |
|
|
1209 | to simply invert the flow control - don't call us, we will call you: |
|
|
1210 | |
|
|
1211 | async { |
|
|
1212 | Coro::AnyEvent::sleep 5; # creates a 5s timer and waits for it |
|
|
1213 | print "5 seconds later!\n"; |
|
|
1214 | |
|
|
1215 | Coro::AnyEvent::readable *STDIN; # uses an I/O watcher |
|
|
1216 | my $line = <STDIN>; # works for ttys |
|
|
1217 | |
|
|
1218 | AnyEvent::HTTP::http_get "url", Coro::rouse_cb; |
|
|
1219 | my ($body, $hdr) = Coro::rouse_wait; |
|
|
1220 | }; |
1211 | |
1221 | |
1212 | =back |
1222 | =back |
1213 | |
1223 | |
1214 | =cut |
1224 | =cut |
1215 | |
1225 | |
… | |
… | |
1225 | |
1235 | |
1226 | BEGIN { AnyEvent::common_sense } |
1236 | BEGIN { AnyEvent::common_sense } |
1227 | |
1237 | |
1228 | use Carp (); |
1238 | use Carp (); |
1229 | |
1239 | |
1230 | our $VERSION = '6.01'; |
1240 | our $VERSION = '6.02'; |
1231 | our $MODEL; |
1241 | our $MODEL; |
1232 | |
|
|
1233 | our @ISA; |
1242 | our @ISA; |
1234 | |
|
|
1235 | our @REGISTRY; |
1243 | our @REGISTRY; |
1236 | |
|
|
1237 | our $VERBOSE; |
1244 | our $VERBOSE; |
|
|
1245 | our $MAX_SIGNAL_LATENCY = 10; |
|
|
1246 | our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred |
1238 | |
1247 | |
1239 | BEGIN { |
1248 | BEGIN { |
1240 | require "AnyEvent/constants.pl"; |
1249 | require "AnyEvent/constants.pl"; |
1241 | |
1250 | |
1242 | eval "sub TAINT (){" . (${^TAINT}*1) . "}"; |
1251 | eval "sub TAINT (){" . (${^TAINT}*1) . "}"; |
… | |
… | |
1248 | for grep s/^AE_// && !exists $ENV{"PERL_ANYEVENT_$_"}, keys %ENV; |
1257 | for grep s/^AE_// && !exists $ENV{"PERL_ANYEVENT_$_"}, keys %ENV; |
1249 | |
1258 | |
1250 | @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} = () |
1259 | @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} = () |
1251 | if ${^TAINT}; |
1260 | if ${^TAINT}; |
1252 | |
1261 | |
1253 | $VERBOSE = $ENV{PERL_ANYEVENT_VERBOSE}*1; |
1262 | # $ENV{PERL_ANYEVENT_xxx} now valid |
1254 | } |
|
|
1255 | |
1263 | |
1256 | our $MAX_SIGNAL_LATENCY = 10; |
1264 | $VERBOSE = length $ENV{PERL_ANYEVENT_VERBOSE} ? $ENV{PERL_ANYEVENT_VERBOSE}*1 : 3; |
1257 | |
1265 | |
1258 | our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred |
|
|
1259 | |
|
|
1260 | { |
|
|
1261 | my $idx; |
1266 | my $idx; |
1262 | $PROTOCOL{$_} = ++$idx |
1267 | $PROTOCOL{$_} = ++$idx |
1263 | for reverse split /\s*,\s*/, |
1268 | for reverse split /\s*,\s*/, |
1264 | $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
1269 | $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
1265 | } |
1270 | } |
… | |
… | |
1328 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1333 | [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza |
1329 | [Wx:: => AnyEvent::Impl::POE::], |
1334 | [Wx:: => AnyEvent::Impl::POE::], |
1330 | [Prima:: => AnyEvent::Impl::POE::], |
1335 | [Prima:: => AnyEvent::Impl::POE::], |
1331 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # a bitch to autodetect |
1336 | [IO::Async::Loop:: => AnyEvent::Impl::IOAsync::], # a bitch to autodetect |
1332 | [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], |
1337 | [Cocoa::EventLoop:: => AnyEvent::Impl::Cocoa::], |
1333 | [FLTK:: => AnyEvent::Impl::FLTK2::], |
1338 | [FLTK:: => AnyEvent::Impl::FLTK::], |
1334 | ); |
1339 | ); |
1335 | |
1340 | |
1336 | our @isa_hook; |
1341 | our @isa_hook; |
1337 | |
1342 | |
1338 | sub _isa_set { |
1343 | sub _isa_set { |
… | |
… | |
2032 | |
2037 | |
2033 | =over 4 |
2038 | =over 4 |
2034 | |
2039 | |
2035 | =item C<PERL_ANYEVENT_VERBOSE> |
2040 | =item C<PERL_ANYEVENT_VERBOSE> |
2036 | |
2041 | |
2037 | By default, AnyEvent will be completely silent except in fatal |
2042 | By default, AnyEvent will only log messages with loglevel C<3> |
2038 | conditions. You can set this environment variable to make AnyEvent more |
2043 | (C<critical>) or higher (see L<AnyEvent::Log>). You can set this |
|
|
2044 | environment variable to a numerical loglevel to make AnyEvent more (or |
|
|
2045 | less) talkative. |
|
|
2046 | |
2039 | talkative. If you want to do more than just set the global logging level |
2047 | If you want to do more than just set the global logging level |
2040 | you should have a look at C<PERL_ANYEVENT_LOG>, which allows much more |
2048 | you should have a look at C<PERL_ANYEVENT_LOG>, which allows much more |
2041 | complex specifications. |
2049 | complex specifications. |
2042 | |
2050 | |
|
|
2051 | When set to C<0> (C<off>), then no messages whatsoever will be logged with |
|
|
2052 | the default logging settings. |
|
|
2053 | |
2043 | When set to C<5> or higher (warn), causes AnyEvent to warn about unexpected |
2054 | When set to C<5> or higher (C<warn>), causes AnyEvent to warn about |
2044 | conditions, such as not being able to load the event model specified by |
2055 | unexpected conditions, such as not being able to load the event model |
2045 | C<PERL_ANYEVENT_MODEL>, or a guard callback throwing an exception - this |
2056 | specified by C<PERL_ANYEVENT_MODEL>, or a guard callback throwing an |
2046 | is the minimum recommended level. |
2057 | exception - this is the minimum recommended level. |
2047 | |
2058 | |
2048 | When set to C<7> or higher (info), cause AnyEvent to report which event model it |
2059 | When set to C<7> or higher (info), cause AnyEvent to report which event model it |
2049 | chooses. |
2060 | chooses. |
2050 | |
2061 | |
2051 | When set to C<8> or higher (debug), then AnyEvent will report extra information on |
2062 | When set to C<8> or higher (debug), then AnyEvent will report extra information on |