… | |
… | |
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 = '2.5'; |
46 | our $VERSION = '3.0'; |
47 | |
47 | |
48 | our @EXPORT = qw(async cede schedule terminate current); |
48 | our @EXPORT = qw(async cede schedule terminate current); |
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 | ); |
… | |
… | |
233 | by calling the ready method. |
233 | by calling the ready method. |
234 | |
234 | |
235 | =cut |
235 | =cut |
236 | |
236 | |
237 | sub _new_coro { |
237 | sub _new_coro { |
238 | $current->_clear_idle_sp; # (re-)set the idle sp on the following cede |
|
|
239 | _set_cede_self; # ensures that cede cede's us first |
|
|
240 | cede; |
|
|
241 | terminate &{+shift}; |
238 | terminate &{+shift}; |
242 | } |
239 | } |
243 | |
240 | |
244 | sub new { |
241 | sub new { |
245 | my $class = shift; |
242 | my $class = shift; |