--- cvsroot/AnyEvent/README 2015/05/02 14:39:31 1.74 +++ cvsroot/AnyEvent/README 2017/07/01 15:48:51 1.78 @@ -814,8 +814,8 @@ "croak" have been called. $cb = $cv->cb ($cb->($cv)) - This is a mutator function that returns the callback set and - optionally replaces it before doing so. + This is a mutator function that returns the callback set (or "undef" + if not) and optionally replaces it before doing so. The callback will be called when the condition becomes "true", i.e. when "send" or "croak" are called, with the only argument being the @@ -823,6 +823,10 @@ callback is called immediately when it is set. Calling "recv" inside the callback or at any later time is guaranteed not to block. + Additionally, when the callback is invoked, it is also removed from + the condvar (reset to "undef"), so the condvar does not keep a + reference to the callback after invocation. + SUPPORTED EVENT LOOPS/BACKENDS The available backend classes are (every class has its own manpage): @@ -912,13 +916,12 @@ model is autodetected (or immediately if that has already happened). The block will be executed *after* the actual backend has been - detected ($AnyEvent::MODEL is set), but *before* any watchers have - been created, so it is possible to e.g. patch @AnyEvent::ISA or do - other initialisations - see the sources of AnyEvent::Strict or - AnyEvent::AIO to see how this is used. + detected ($AnyEvent::MODEL is set), so it is possible to do some + initialisation only when AnyEvent is actually initialised - see the + sources of AnyEvent::AIO to see how this is used. The most common usage is to create some global watchers, without - forcing event module detection too early, for example, AnyEvent::AIO + forcing event module detection too early. For example, AnyEvent::AIO creates and installs the global IO::AIO watcher in a "post_detect" block to avoid autodetecting the event module at load time. @@ -944,9 +947,16 @@ $WATCHER ||= $guard; @AnyEvent::post_detect - If there are any code references in this array (you can "push" to it - before or after loading AnyEvent), then they will be called directly - after the event loop has been chosen. + This is a lower level interface then "AnyEvent::post_detect" (the + function). This variable is mainly useful for modules that can do + something useful when AnyEvent is used and thus want to know when it + is initialised, but do not need to even load it by default. This + array provides the means to hook into AnyEvent passively, without + loading it. + + Here is how it works: If there are any code references in this array + (you can "push" to it before or after loading AnyEvent), then they + will be called directly after the event loop has been chosen. You should check $AnyEvent::MODEL before adding to this array, though: if it is defined then the event loop has already been @@ -955,12 +965,6 @@ Best use "AnyEvent::post_detect { BLOCK }" when your application allows it, as it takes care of these details. - This variable is mainly useful for modules that can do something - useful when AnyEvent is used and thus want to know when it is - initialised, but do not need to even load it by default. This array - provides the means to hook into AnyEvent passively, without loading - it. - Example: To load Coro::AnyEvent whenever Coro and AnyEvent are used together, you could put this into Coro (this is the actual code used by Coro to accomplish this): @@ -1032,6 +1036,10 @@ function, which can reduce typing, codesize and can reduce the logging overhead enourmously. + AnyEvent::fh_block $filehandle + AnyEvent::fh_unblock $filehandle + Sets blocking or non-blocking behaviour for the given filehandle. + WHAT TO DO IN A MODULE As a module author, you should "use AnyEvent" and call AnyEvent methods freely, but you should not load a specific event module or rely on it. @@ -1606,7 +1614,7 @@ ... }); - EV::loop; + EV::run; 3b. The module user could use AnyEvent, too: