… | |
… | |
671 | returning a new coderef. Unblocking means that calling the new coderef |
671 | returning a new coderef. Unblocking means that calling the new coderef |
672 | will return immediately without blocking, returning nothing, while the |
672 | will return immediately without blocking, returning nothing, while the |
673 | original code ref will be called (with parameters) from within another |
673 | original code ref will be called (with parameters) from within another |
674 | coro. |
674 | coro. |
675 | |
675 | |
676 | The reason this function exists is that many event libraries (such as the |
676 | The reason this function exists is that many event libraries (such as |
677 | venerable L<Event|Event> module) are not thread-safe (a weaker form |
677 | the venerable L<Event|Event> module) are not thread-safe (a weaker form |
678 | of reentrancy). This means you must not block within event callbacks, |
678 | of reentrancy). This means you must not block within event callbacks, |
679 | otherwise you might suffer from crashes or worse. The only event library |
679 | otherwise you might suffer from crashes or worse. The only event library |
680 | currently known that is safe to use without C<unblock_sub> is L<EV>. |
680 | currently known that is safe to use without C<unblock_sub> is L<EV> (but |
|
|
681 | you might still run into deadlocks if all event loops are blocked). |
681 | |
682 | |
682 | Coro will try to catch you when you block in the event loop |
683 | Coro will try to catch you when you block in the event loop |
683 | ("FATAL:$Coro::IDLE blocked itself"), but this is just best effort and |
684 | ("FATAL:$Coro::IDLE blocked itself"), but this is just best effort and |
684 | only works when you do not run your own event loop. |
685 | only works when you do not run your own event loop. |
685 | |
686 | |