ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro.pm
(Generate patch)

Comparing Coro/Coro.pm (file contents):
Revision 1.280 by root, Thu Nov 11 15:07:16 2010 UTC vs.
Revision 1.282 by root, Sun Dec 26 16:23:51 2010 UTC

671returning a new coderef. Unblocking means that calling the new coderef 671returning a new coderef. Unblocking means that calling the new coderef
672will return immediately without blocking, returning nothing, while the 672will return immediately without blocking, returning nothing, while the
673original code ref will be called (with parameters) from within another 673original code ref will be called (with parameters) from within another
674coro. 674coro.
675 675
676The reason this function exists is that many event libraries (such as the 676The reason this function exists is that many event libraries (such as
677venerable L<Event|Event> module) are not thread-safe (a weaker form 677the venerable L<Event|Event> module) are not thread-safe (a weaker form
678of reentrancy). This means you must not block within event callbacks, 678of reentrancy). This means you must not block within event callbacks,
679otherwise you might suffer from crashes or worse. The only event library 679otherwise you might suffer from crashes or worse. The only event library
680currently known that is safe to use without C<unblock_sub> is L<EV>. 680currently known that is safe to use without C<unblock_sub> is L<EV> (but
681you might still run into deadlocks if all event loops are blocked).
681 682
682Coro will try to catch you when you block in the event loop 683Coro 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
684only works when you do not run your own event loop. 685only works when you do not run your own event loop.
685 686
868ithreads (for example, that memory or files would be shared), showing his 869ithreads (for example, that memory or files would be shared), showing his
869lack of understanding of this area - if it is hard to understand for Chip, 870lack of understanding of this area - if it is hard to understand for Chip,
870it is probably not obvious to everybody). 871it is probably not obvious to everybody).
871 872
872What follows is an ultra-condensed version of my talk about threads in 873What follows is an ultra-condensed version of my talk about threads in
873scripting languages given onthe perl workshop 2009: 874scripting languages given on the perl workshop 2009:
874 875
875The so-called "ithreads" were originally implemented for two reasons: 876The so-called "ithreads" were originally implemented for two reasons:
876first, to (badly) emulate unix processes on native win32 perls, and 877first, to (badly) emulate unix processes on native win32 perls, and
877secondly, to replace the older, real thread model ("5.005-threads"). 878secondly, to replace the older, real thread model ("5.005-threads").
878 879

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines