… | |
… | |
41 | |
41 | |
42 | our $idle; # idle handler |
42 | our $idle; # idle handler |
43 | our $main; # main coroutine |
43 | our $main; # main coroutine |
44 | our $current; # current coroutine |
44 | our $current; # current coroutine |
45 | |
45 | |
46 | our $VERSION = '3.0'; |
46 | our $VERSION = '3.01'; |
47 | |
47 | |
48 | our @EXPORT = qw(async cede schedule terminate current unblock_sub); |
48 | our @EXPORT = qw(async cede schedule terminate current unblock_sub); |
49 | our %EXPORT_TAGS = ( |
49 | our %EXPORT_TAGS = ( |
50 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
50 | prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], |
51 | ); |
51 | ); |
… | |
… | |
254 | |
254 | |
255 | Calling C<exit> in a coroutine will not work correctly, so do not do that. |
255 | Calling C<exit> in a coroutine will not work correctly, so do not do that. |
256 | |
256 | |
257 | =cut |
257 | =cut |
258 | |
258 | |
259 | sub _new_coro { |
259 | sub _run_coro { |
260 | terminate &{+shift}; |
260 | terminate &{+shift}; |
261 | } |
261 | } |
262 | |
262 | |
263 | sub new { |
263 | sub new { |
264 | my $class = shift; |
264 | my $class = shift; |
265 | |
265 | |
266 | $class->SUPER::new (\&_new_coro, @_) |
266 | $class->SUPER::new (\&_run_coro, @_) |
267 | } |
267 | } |
268 | |
268 | |
269 | =item $success = $coroutine->ready |
269 | =item $success = $coroutine->ready |
270 | |
270 | |
271 | Put the given coroutine into the ready queue (according to it's priority) |
271 | Put the given coroutine into the ready queue (according to it's priority) |