… | |
… | |
811 | |
811 | |
812 | In list context, all parameters passed to C<send> will be returned, |
812 | In list context, all parameters passed to C<send> will be returned, |
813 | in scalar context only the first one will be returned. |
813 | in scalar context only the first one will be returned. |
814 | |
814 | |
815 | Note that doing a blocking wait in a callback is not supported by any |
815 | Note that doing a blocking wait in a callback is not supported by any |
816 | event loop, that is, recursive invocation of a blocking C<< ->recv |
816 | event loop, that is, recursive invocation of a blocking C<< ->recv >> is |
817 | >> is not allowed, and the C<recv> call will C<croak> if such a |
817 | not allowed and the C<recv> call will C<croak> if such a condition is |
818 | condition is detected. This condition can be slightly loosened by using |
818 | detected. This requirement can be dropped by relying on L<Coro::AnyEvent> |
819 | L<Coro::AnyEvent>, which allows you to do a blocking C<< ->recv >> from |
819 | , which allows you to do a blocking C<< ->recv >> from any thread |
820 | any thread that doesn't run the event loop itself. |
820 | that doesn't run the event loop itself. L<Coro::AnyEvent> is loaded |
|
|
821 | automatically when L<Coro> is used with L<AnyEvent>, so code does not need |
|
|
822 | to do anything special to take advantage of that: any code that would |
|
|
823 | normally block your program because it calls C<recv>, be executed in an |
|
|
824 | C<async> thread instead without blocking other threads. |
821 | |
825 | |
822 | Not all event models support a blocking wait - some die in that case |
826 | Not all event models support a blocking wait - some die in that case |
823 | (programs might want to do that to stay interactive), so I<if you are |
827 | (programs might want to do that to stay interactive), so I<if you are |
824 | using this from a module, never require a blocking wait>. Instead, let the |
828 | using this from a module, never require a blocking wait>. Instead, let the |
825 | caller decide whether the call will block or not (for example, by coupling |
829 | caller decide whether the call will block or not (for example, by coupling |