… | |
… | |
67 | |
67 | |
68 | our $idle; # idle handler |
68 | our $idle; # idle handler |
69 | our $main; # main coroutine |
69 | our $main; # main coroutine |
70 | our $current; # current coroutine |
70 | our $current; # current coroutine |
71 | |
71 | |
72 | our $VERSION = 4.911; |
72 | our $VERSION = 5.0; |
73 | |
73 | |
74 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
74 | our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); |
75 | our %EXPORT_TAGS = ( |
75 | our %EXPORT_TAGS = ( |
76 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
76 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
77 | ); |
77 | ); |
… | |
… | |
275 | } |
275 | } |
276 | } |
276 | } |
277 | } |
277 | } |
278 | |
278 | |
279 | sub async_pool(&@) { |
279 | sub async_pool(&@) { |
280 | # this is also inlined into the unlock_scheduler |
280 | # this is also inlined into the unblock_scheduler |
281 | my $coro = (pop @async_pool) || new Coro \&pool_handler; |
281 | my $coro = (pop @async_pool) || new Coro \&pool_handler; |
282 | |
282 | |
283 | $coro->{_invoke} = [@_]; |
283 | $coro->{_invoke} = [@_]; |
284 | $coro->ready; |
284 | $coro->ready; |
285 | |
285 | |
… | |
… | |
665 | |
665 | |
666 | 1; |
666 | 1; |
667 | |
667 | |
668 | =head1 BUGS/LIMITATIONS |
668 | =head1 BUGS/LIMITATIONS |
669 | |
669 | |
|
|
670 | =over 4 |
|
|
671 | |
|
|
672 | =item perl process emulation ("threads") |
|
|
673 | |
670 | This module is not perl-pseudo-thread-safe. You should only ever use this |
674 | This module is not perl-pseudo-thread-safe. You should only ever use this |
671 | module from the same thread (this requirement might be removed in the |
675 | module from the same thread (this requirement might be removed in the |
672 | future to allow per-thread schedulers, but Coro::State does not yet allow |
676 | future to allow per-thread schedulers, but Coro::State does not yet allow |
673 | this). I recommend disabling thread support and using processes, as this |
677 | this). I recommend disabling thread support and using processes, as having |
674 | is much faster and uses less memory. |
678 | the windows process emulation enabled under unix roughly halves perl |
|
|
679 | performance, even when not used. |
|
|
680 | |
|
|
681 | =item coroutine switching not signal safe |
|
|
682 | |
|
|
683 | You must not switch to another coroutine from within a signal handler |
|
|
684 | (only relevant with %SIG - most event libraries provide safe signals). |
|
|
685 | |
|
|
686 | That means you I<MUST NOT> call any fucntion that might "block" the |
|
|
687 | current coroutine - C<cede>, C<schedule> C<< Coro::Semaphore->down >> or |
|
|
688 | anything that calls those. Everything else, including calling C<ready>, |
|
|
689 | works. |
|
|
690 | |
|
|
691 | =back |
|
|
692 | |
675 | |
693 | |
676 | =head1 SEE ALSO |
694 | =head1 SEE ALSO |
677 | |
695 | |
678 | Event-Loop integration: L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>. |
696 | Event-Loop integration: L<Coro::AnyEvent>, L<Coro::EV>, L<Coro::Event>. |
679 | |
697 | |