… | |
… | |
66 | |
66 | |
67 | our $idle; # idle handler |
67 | our $idle; # idle handler |
68 | our $main; # main coroutine |
68 | our $main; # main coroutine |
69 | our $current; # current coroutine |
69 | our $current; # current coroutine |
70 | |
70 | |
71 | our $VERSION = 4.6; |
71 | our $VERSION = 4.744; |
72 | |
72 | |
73 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
73 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
74 | our %EXPORT_TAGS = ( |
74 | our %EXPORT_TAGS = ( |
75 | 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)], |
76 | ); |
76 | ); |
… | |
… | |
266 | _pool_2 $cb; |
266 | _pool_2 $cb; |
267 | &schedule; |
267 | &schedule; |
268 | } |
268 | } |
269 | }; |
269 | }; |
270 | |
270 | |
|
|
271 | if ($@) { |
271 | last if $@ eq "\3async_pool terminate\2\n"; |
272 | last if $@ eq "\3async_pool terminate\2\n"; |
272 | warn $@ if $@; |
273 | warn $@; |
|
|
274 | } |
273 | } |
275 | } |
274 | } |
276 | } |
275 | |
277 | |
276 | sub async_pool(&@) { |
278 | sub async_pool(&@) { |
277 | # this is also inlined into the unlock_scheduler |
279 | # this is also inlined into the unlock_scheduler |
… | |
… | |
611 | creating event callbacks that want to block. |
613 | creating event callbacks that want to block. |
612 | |
614 | |
613 | If your handler does not plan to block (e.g. simply sends a message to |
615 | If your handler does not plan to block (e.g. simply sends a message to |
614 | another coroutine, or puts some other coroutine into the ready queue), |
616 | another coroutine, or puts some other coroutine into the ready queue), |
615 | there is no reason to use C<unblock_sub>. |
617 | there is no reason to use C<unblock_sub>. |
|
|
618 | |
|
|
619 | Note that you also need to use C<unblock_sub> for any other callbacks that |
|
|
620 | are indirectly executed by any C-based event loop. For example, when you |
|
|
621 | use a module that uses L<AnyEvent> (and you use L<Coro::AnyEvent>) and it |
|
|
622 | provides callbacks that are the result of some event callback, then you |
|
|
623 | must not block either, or use C<unblock_sub>. |
616 | |
624 | |
617 | =cut |
625 | =cut |
618 | |
626 | |
619 | our @unblock_queue; |
627 | our @unblock_queue; |
620 | |
628 | |