1 | NAME |
1 | NAME |
2 | AnyEvent - the DBI of event loop programming |
2 | AnyEvent - the DBI of event loop programming |
3 | |
3 | |
4 | EV, Event, Glib, Tk, Perl, Event::Lib, Irssi, rxvt-unicode, IO::Async, |
4 | EV, Event, Glib, Tk, Perl, Event::Lib, Irssi, rxvt-unicode, IO::Async, |
5 | Qt and POE are various supported event loops/environments. |
5 | Qt, FLTK and POE are various supported event loops/environments. |
6 | |
6 | |
7 | SYNOPSIS |
7 | SYNOPSIS |
8 | use AnyEvent; |
8 | use AnyEvent; |
9 | |
9 | |
10 | # if you prefer function calls, look at the AE manpage for |
10 | # if you prefer function calls, look at the AE manpage for |
… | |
… | |
1002 | It should use "postpone": |
1002 | It should use "postpone": |
1003 | |
1003 | |
1004 | AnyEvent::postpone { $cb->(undef) }, return # signal error to callback, later |
1004 | AnyEvent::postpone { $cb->(undef) }, return # signal error to callback, later |
1005 | if $some_error_condition; |
1005 | if $some_error_condition; |
1006 | |
1006 | |
|
|
1007 | AnyEvent::log $level, $msg[, @args] |
|
|
1008 | Log the given $msg at the given $level. |
|
|
1009 | |
|
|
1010 | Loads AnyEvent::Log on first use and calls "AnyEvent::Log::log" - |
|
|
1011 | consequently, look at the AnyEvent::Log documentation for details. |
|
|
1012 | |
|
|
1013 | If you want to sprinkle loads of logging calls around your code, |
|
|
1014 | consider creating a logger callback with the "AnyEvent::Log::logger" |
|
|
1015 | function. |
|
|
1016 | |
1007 | WHAT TO DO IN A MODULE |
1017 | WHAT TO DO IN A MODULE |
1008 | As a module author, you should "use AnyEvent" and call AnyEvent methods |
1018 | As a module author, you should "use AnyEvent" and call AnyEvent methods |
1009 | freely, but you should not load a specific event module or rely on it. |
1019 | freely, but you should not load a specific event module or rely on it. |
1010 | |
1020 | |
1011 | Be careful when you create watchers in the module body - AnyEvent will |
1021 | Be careful when you create watchers in the module body - AnyEvent will |
… | |
… | |
1064 | |
1074 | |
1065 | OTHER MODULES |
1075 | OTHER MODULES |
1066 | The following is a non-exhaustive list of additional modules that use |
1076 | The following is a non-exhaustive list of additional modules that use |
1067 | AnyEvent as a client and can therefore be mixed easily with other |
1077 | AnyEvent as a client and can therefore be mixed easily with other |
1068 | AnyEvent modules and other event loops in the same program. Some of the |
1078 | AnyEvent modules and other event loops in the same program. Some of the |
1069 | modules come as part of AnyEvent, the others are available via CPAN. |
1079 | modules come as part of AnyEvent, the others are available via CPAN (see |
|
|
1080 | <http://search.cpan.org/search?m=module&q=anyevent%3A%3A*> for a longer |
|
|
1081 | non-exhaustive list), and the list is heavily biased towards modules of |
|
|
1082 | the AnyEvent author himself :) |
1070 | |
1083 | |
1071 | AnyEvent::Util |
1084 | AnyEvent::Util |
1072 | Contains various utility functions that replace often-used blocking |
1085 | Contains various utility functions that replace often-used blocking |
1073 | functions such as "inet_aton" with event/callback-based versions. |
1086 | functions such as "inet_aton" with event/callback-based versions. |
1074 | |
1087 | |
… | |
… | |
1162 | "PERL_ANYEVENT_VERBOSE" |
1175 | "PERL_ANYEVENT_VERBOSE" |
1163 | By default, AnyEvent will be completely silent except in fatal |
1176 | By default, AnyEvent will be completely silent except in fatal |
1164 | conditions. You can set this environment variable to make AnyEvent |
1177 | conditions. You can set this environment variable to make AnyEvent |
1165 | more talkative. |
1178 | more talkative. |
1166 | |
1179 | |
1167 | When set to 1 or higher, causes AnyEvent to warn about unexpected |
1180 | When set to 5 or higher, causes AnyEvent to warn about unexpected |
1168 | conditions, such as not being able to load the event model specified |
1181 | conditions, such as not being able to load the event model specified |
1169 | by "PERL_ANYEVENT_MODEL". |
1182 | by "PERL_ANYEVENT_MODEL". |
1170 | |
1183 | |
1171 | When set to 2 or higher, cause AnyEvent to report to STDERR which |
1184 | When set to 7 or higher, cause AnyEvent to report to STDERR which |
1172 | event model it chooses. |
1185 | event model it chooses. |
1173 | |
1186 | |
1174 | When set to 8 or higher, then AnyEvent will report extra information |
1187 | When set to 8 or higher, then AnyEvent will report extra information |
1175 | on which optional modules it loads and how it implements certain |
1188 | on which optional modules it loads and how it implements certain |
1176 | features. |
1189 | features. |
… | |
… | |
1199 | This takes place when the first watcher is created. |
1212 | This takes place when the first watcher is created. |
1200 | |
1213 | |
1201 | For example, to bind a debug shell on a unix domain socket in |
1214 | For example, to bind a debug shell on a unix domain socket in |
1202 | /tmp/debug<pid>.sock, you could use this: |
1215 | /tmp/debug<pid>.sock, you could use this: |
1203 | |
1216 | |
1204 | PERL_ANYEVENT_DEBUG_SHELL=unix/:/tmp/debug\$\$.sock perlprog |
1217 | PERL_ANYEVENT_DEBUG_SHELL=/tmp/debug\$\$.sock perlprog |
1205 | |
1218 | |
1206 | Note that creating sockets in /tmp is very unsafe on multiuser |
1219 | Note that creating sockets in /tmp is very unsafe on multiuser |
1207 | systems. |
1220 | systems. |
1208 | |
1221 | |
1209 | "PERL_ANYEVENT_DEBUG_WRAP" |
1222 | "PERL_ANYEVENT_DEBUG_WRAP" |
… | |
… | |
1606 | when used without AnyEvent), but most event loops have acceptable |
1619 | when used without AnyEvent), but most event loops have acceptable |
1607 | performance with or without AnyEvent. |
1620 | performance with or without AnyEvent. |
1608 | |
1621 | |
1609 | * The overhead AnyEvent adds is usually much smaller than the overhead |
1622 | * The overhead AnyEvent adds is usually much smaller than the overhead |
1610 | of the actual event loop, only with extremely fast event loops such |
1623 | of the actual event loop, only with extremely fast event loops such |
1611 | as EV adds AnyEvent significant overhead. |
1624 | as EV does AnyEvent add significant overhead. |
1612 | |
1625 | |
1613 | * You should avoid POE like the plague if you want performance or |
1626 | * You should avoid POE like the plague if you want performance or |
1614 | reasonable memory usage. |
1627 | reasonable memory usage. |
1615 | |
1628 | |
1616 | BENCHMARKING THE LARGE SERVER CASE |
1629 | BENCHMARKING THE LARGE SERVER CASE |
… | |
… | |
1942 | SEE ALSO |
1955 | SEE ALSO |
1943 | Tutorial/Introduction: AnyEvent::Intro. |
1956 | Tutorial/Introduction: AnyEvent::Intro. |
1944 | |
1957 | |
1945 | FAQ: AnyEvent::FAQ. |
1958 | FAQ: AnyEvent::FAQ. |
1946 | |
1959 | |
1947 | Utility functions: AnyEvent::Util. |
1960 | Utility functions: AnyEvent::Util (misc. grab-bag), AnyEvent::Log |
|
|
1961 | (simply logging). |
1948 | |
1962 | |
|
|
1963 | Development/Debugging: AnyEvent::Strict (stricter checking), |
|
|
1964 | AnyEvent::Debug (interactive shell, watcher tracing). |
|
|
1965 | |
1949 | Event modules: AnyEvent::Loop, EV, EV::Glib, Glib::EV, Event, |
1966 | Supported event modules: AnyEvent::Loop, EV, EV::Glib, Glib::EV, Event, |
1950 | Glib::Event, Glib, Tk, Event::Lib, Qt, POE. |
1967 | Glib::Event, Glib, Tk, Event::Lib, Qt, POE, FLTK. |
1951 | |
1968 | |
1952 | Implementations: AnyEvent::Impl::EV, AnyEvent::Impl::Event, |
1969 | Implementations: AnyEvent::Impl::EV, AnyEvent::Impl::Event, |
1953 | AnyEvent::Impl::Glib, AnyEvent::Impl::Tk, AnyEvent::Impl::Perl, |
1970 | AnyEvent::Impl::Glib, AnyEvent::Impl::Tk, AnyEvent::Impl::Perl, |
1954 | AnyEvent::Impl::EventLib, AnyEvent::Impl::Qt, AnyEvent::Impl::POE, |
1971 | AnyEvent::Impl::EventLib, AnyEvent::Impl::Qt, AnyEvent::Impl::POE, |
1955 | AnyEvent::Impl::IOAsync, Anyevent::Impl::Irssi. |
1972 | AnyEvent::Impl::IOAsync, Anyevent::Impl::Irssi, AnyEvent::Impl::FLTK. |
1956 | |
1973 | |
1957 | Non-blocking file handles, sockets, TCP clients and servers: |
1974 | Non-blocking handles, pipes, stream sockets, TCP clients and servers: |
1958 | AnyEvent::Handle, AnyEvent::Socket, AnyEvent::TLS. |
1975 | AnyEvent::Handle, AnyEvent::Socket, AnyEvent::TLS. |
1959 | |
1976 | |
1960 | Asynchronous DNS: AnyEvent::DNS. |
1977 | Asynchronous DNS: AnyEvent::DNS. |
1961 | |
1978 | |
1962 | Thread support: Coro, Coro::AnyEvent, Coro::EV, Coro::Event. |
1979 | Thread support: Coro, Coro::AnyEvent, Coro::EV, Coro::Event. |