--- AnyEvent/README 2008/05/24 17:58:33 1.22 +++ AnyEvent/README 2008/05/26 06:04:38 1.23 @@ -305,7 +305,8 @@ After creation, the condition variable is "false" until it becomes "true" by calling the "send" method (or calling the condition variable - as if it were a callback). + as if it were a callback, read about the caveats in the description for + the "->send" method). Condition variables are similar to callbacks, except that you can optionally wait for them. They can also be called merge points - points @@ -385,7 +386,12 @@ Condition variables are overloaded so one can call them directly (as a code reference). Calling them directly is the same as calling - "send". + "send". Note, however, that many C-based event loops do not handle + overloading, so as tempting as it may be, passing a condition + variable instead of a callback does not work. Both the pure perl and + EV loops support overloading, however, as well as all functions that + use perl to invoke a callback (as in AnyEvent::Socket and + AnyEvent::DNS for example). $cv->croak ($error) Similar to send, but causes all call's to "->recv" to invoke @@ -580,8 +586,8 @@ AnyEvent decide which implementation to chose if some module relies on it. - If the main program relies on a specific event model. For example, in - Gtk2 programs you have to rely on the Glib module. You should load the + If the main program relies on a specific event model - for example, in + Gtk2 programs you have to rely on the Glib module - you should load the event module before loading AnyEvent or any module that uses it: generally speaking, you should load it as early as possible. The reason is that modules might create watchers when they are loaded, and AnyEvent @@ -589,9 +595,25 @@ and it might chose the wrong one unless you load the correct one yourself. - You can chose to use a rather inefficient pure-perl implementation by - loading the "AnyEvent::Impl::Perl" module, which gives you similar - behaviour everywhere, but letting AnyEvent chose is generally better. + You can chose to use a pure-perl implementation by loading the + "AnyEvent::Impl::Perl" module, which gives you similar behaviour + everywhere, but letting AnyEvent chose the model is generally better. + + MAINLOOP EMULATION + Sometimes (often for short test scripts, or even standalone programs who + only want to use AnyEvent), you do not want to run a specific event + loop. + + In that case, you can use a condition variable like this: + + AnyEvent->condvar->recv; + + This has the effect of entering the event loop and looping forever. + + Note that usually your program has some exit condition, in which case it + is better to use the "traditional" approach of storing a condition + variable somewhere, waiting for it, and sending it when the program + should exit cleanly. OTHER MODULES The following is a non-exhaustive list of additional modules that use @@ -614,12 +636,12 @@ tcp connections or tcp servers, with IPv6 and SRV record support and more. - AnyEvent::HTTPD - Provides a simple web application server framework. - AnyEvent::DNS Provides rich asynchronous DNS resolver capabilities. + AnyEvent::HTTPD + Provides a simple web application server framework. + AnyEvent::FastPing The fastest ping in the west.