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

Comparing Coro/Coro.pm (file contents):
Revision 1.181 by root, Fri May 9 22:04:37 2008 UTC vs.
Revision 1.191 by root, Sat May 31 12:10:55 2008 UTC

35parallel access are rarely an issue, making coroutine programming much 35parallel access are rarely an issue, making coroutine programming much
36safer and easier than threads programming. 36safer and easier than threads programming.
37 37
38Unlike a normal perl program, however, coroutines allow you to have 38Unlike a normal perl program, however, coroutines allow you to have
39multiple running interpreters that share data, which is especially useful 39multiple running interpreters that share data, which is especially useful
40to code pseudo-parallel processes, such as multiple HTTP-GET requests 40to code pseudo-parallel processes and for event-based programming, such as
41running concurrently. 41multiple HTTP-GET requests running concurrently. See L<Coro::AnyEvent> to
42learn more.
42 43
43Coroutines are also useful because Perl has no support for threads (the so 44Coroutines are also useful because Perl has no support for threads (the so
44called "threads" that perl offers are nothing more than the (bad) process 45called "threads" that perl offers are nothing more than the (bad) process
45emulation coming from the Windows platform: On standard operating systems 46emulation coming from the Windows platform: On standard operating systems
46they serve no purpose whatsoever, except by making your programs slow and 47they serve no purpose whatsoever, except by making your programs slow and
65 66
66our $idle; # idle handler 67our $idle; # idle handler
67our $main; # main coroutine 68our $main; # main coroutine
68our $current; # current coroutine 69our $current; # current coroutine
69 70
70our $VERSION = 4.6; 71our $VERSION = 4.742;
71 72
72our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); 73our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub);
73our %EXPORT_TAGS = ( 74our %EXPORT_TAGS = (
74 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], 75 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)],
75); 76);
611 612
612If your handler does not plan to block (e.g. simply sends a message to 613If your handler does not plan to block (e.g. simply sends a message to
613another coroutine, or puts some other coroutine into the ready queue), 614another coroutine, or puts some other coroutine into the ready queue),
614there is no reason to use C<unblock_sub>. 615there is no reason to use C<unblock_sub>.
615 616
617Note that you also need to use C<unblock_sub> for any other callbacks that
618are indirectly executed by any C-based event loop. For example, when you
619use a module that uses L<AnyEvent> (and you use L<Coro::AnyEvent>) and it
620provides callbacks that are the result of some event callback, then you
621must not block either, or use C<unblock_sub>.
622
616=cut 623=cut
617 624
618our @unblock_queue; 625our @unblock_queue;
619 626
620# we create a special coro because we want to cede, 627# we create a special coro because we want to cede,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines