… | |
… | |
812 | $bool = $cv->ready |
812 | $bool = $cv->ready |
813 | Returns true when the condition is "true", i.e. whether "send" or |
813 | Returns true when the condition is "true", i.e. whether "send" or |
814 | "croak" have been called. |
814 | "croak" have been called. |
815 | |
815 | |
816 | $cb = $cv->cb ($cb->($cv)) |
816 | $cb = $cv->cb ($cb->($cv)) |
817 | This is a mutator function that returns the callback set and |
817 | This is a mutator function that returns the callback set (or "undef" |
818 | optionally replaces it before doing so. |
818 | if not) and optionally replaces it before doing so. |
819 | |
819 | |
820 | The callback will be called when the condition becomes "true", i.e. |
820 | The callback will be called when the condition becomes "true", i.e. |
821 | when "send" or "croak" are called, with the only argument being the |
821 | when "send" or "croak" are called, with the only argument being the |
822 | condition variable itself. If the condition is already true, the |
822 | condition variable itself. If the condition is already true, the |
823 | callback is called immediately when it is set. Calling "recv" inside |
823 | callback is called immediately when it is set. Calling "recv" inside |
824 | the callback or at any later time is guaranteed not to block. |
824 | the callback or at any later time is guaranteed not to block. |
|
|
825 | |
|
|
826 | Additionally, when the callback is invoked, it is also removed from |
|
|
827 | the condvar (reset to "undef"), so the condvar does not keep a |
|
|
828 | reference to the callback after invocation. |
825 | |
829 | |
826 | SUPPORTED EVENT LOOPS/BACKENDS |
830 | SUPPORTED EVENT LOOPS/BACKENDS |
827 | The available backend classes are (every class has its own manpage): |
831 | The available backend classes are (every class has its own manpage): |
828 | |
832 | |
829 | Backends that are autoprobed when no other event loop can be found. |
833 | Backends that are autoprobed when no other event loop can be found. |
… | |
… | |
1030 | If you want to sprinkle loads of logging calls around your code, |
1034 | If you want to sprinkle loads of logging calls around your code, |
1031 | consider creating a logger callback with the "AnyEvent::Log::logger" |
1035 | consider creating a logger callback with the "AnyEvent::Log::logger" |
1032 | function, which can reduce typing, codesize and can reduce the |
1036 | function, which can reduce typing, codesize and can reduce the |
1033 | logging overhead enourmously. |
1037 | logging overhead enourmously. |
1034 | |
1038 | |
|
|
1039 | AnyEvent::fh_block $filehandle |
|
|
1040 | AnyEvent::fh_unblock $filehandle |
|
|
1041 | Sets blocking or non-blocking behaviour for the given filehandle. |
|
|
1042 | |
1035 | WHAT TO DO IN A MODULE |
1043 | WHAT TO DO IN A MODULE |
1036 | As a module author, you should "use AnyEvent" and call AnyEvent methods |
1044 | As a module author, you should "use AnyEvent" and call AnyEvent methods |
1037 | freely, but you should not load a specific event module or rely on it. |
1045 | freely, but you should not load a specific event module or rely on it. |
1038 | |
1046 | |
1039 | Be careful when you create watchers in the module body - AnyEvent will |
1047 | Be careful when you create watchers in the module body - AnyEvent will |
… | |
… | |
1604 | my $txn = shift; |
1612 | my $txn = shift; |
1605 | my $data = $txn->result; |
1613 | my $data = $txn->result; |
1606 | ... |
1614 | ... |
1607 | }); |
1615 | }); |
1608 | |
1616 | |
1609 | EV::loop; |
1617 | EV::run; |
1610 | |
1618 | |
1611 | 3b. The module user could use AnyEvent, too: |
1619 | 3b. The module user could use AnyEvent, too: |
1612 | |
1620 | |
1613 | use AnyEvent; |
1621 | use AnyEvent; |
1614 | |
1622 | |