… | |
… | |
50 | |
50 | |
51 | our $idle; # idle handler |
51 | our $idle; # idle handler |
52 | our $main; # main coroutine |
52 | our $main; # main coroutine |
53 | our $current; # current coroutine |
53 | our $current; # current coroutine |
54 | |
54 | |
55 | our $VERSION = '3.55'; |
55 | our $VERSION = '3.56'; |
56 | |
56 | |
57 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
57 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
58 | our %EXPORT_TAGS = ( |
58 | our %EXPORT_TAGS = ( |
59 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
59 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
60 | ); |
60 | ); |
… | |
… | |
185 | |
185 | |
186 | Create a new asynchronous coroutine and return it's coroutine object |
186 | Create a new asynchronous coroutine and return it's coroutine object |
187 | (usually unused). When the sub returns the new coroutine is automatically |
187 | (usually unused). When the sub returns the new coroutine is automatically |
188 | terminated. |
188 | terminated. |
189 | |
189 | |
190 | Calling C<exit> in a coroutine will not work correctly, so do not do that. |
190 | Calling C<exit> in a coroutine will try to do the same as calling exit |
|
|
191 | outside the coroutine, but this is experimental. It is best not to rely on |
|
|
192 | exit doing any cleanups or even not crashing. |
191 | |
193 | |
192 | When the coroutine dies, the program will exit, just as in the main |
194 | When the coroutine dies, the program will exit, just as in the main |
193 | program. |
195 | program. |
194 | |
196 | |
195 | # create a new coroutine that just prints its arguments |
197 | # create a new coroutine that just prints its arguments |
… | |
… | |
326 | Create a new coroutine and return it. When the sub returns the coroutine |
328 | Create a new coroutine and return it. When the sub returns the coroutine |
327 | automatically terminates as if C<terminate> with the returned values were |
329 | automatically terminates as if C<terminate> with the returned values were |
328 | called. To make the coroutine run you must first put it into the ready queue |
330 | called. To make the coroutine run you must first put it into the ready queue |
329 | by calling the ready method. |
331 | by calling the ready method. |
330 | |
332 | |
331 | Calling C<exit> in a coroutine will not work correctly, so do not do that. |
333 | See C<async> for additional discussion. |
332 | |
334 | |
333 | =cut |
335 | =cut |
334 | |
336 | |
335 | sub _run_coro { |
337 | sub _run_coro { |
336 | terminate &{+shift}; |
338 | terminate &{+shift}; |