… | |
… | |
26 | |
26 | |
27 | use Coro::State; |
27 | use Coro::State; |
28 | |
28 | |
29 | use base Exporter; |
29 | use base Exporter; |
30 | |
30 | |
31 | $VERSION = 0.04; |
31 | $VERSION = 0.05; |
32 | |
32 | |
33 | @EXPORT = qw(async yield schedule); |
33 | @EXPORT = qw(async yield schedule); |
34 | @EXPORT_OK = qw($current); |
34 | @EXPORT_OK = qw($current); |
35 | |
35 | |
36 | { |
36 | { |
… | |
… | |
129 | =cut |
129 | =cut |
130 | |
130 | |
131 | my $prev; |
131 | my $prev; |
132 | |
132 | |
133 | sub schedule { |
133 | sub schedule { |
|
|
134 | local @_; |
134 | # should be done using priorities :( |
135 | # should be done using priorities :( |
135 | ($prev, $current) = ($current, shift @ready || $idle); |
136 | ($prev, $current) = ($current, shift @ready || $idle); |
136 | Coro::State::transfer($prev, $current); |
137 | Coro::State::transfer($prev, $current); |
137 | } |
138 | } |
138 | |
139 | |