… | |
… | |
31 | |
31 | |
32 | use Coro::State; |
32 | use Coro::State; |
33 | |
33 | |
34 | use base Exporter; |
34 | use base Exporter; |
35 | |
35 | |
36 | $VERSION = 0.06; |
36 | $VERSION = 0.08; |
37 | |
37 | |
38 | @EXPORT = qw(async yield schedule terminate); |
38 | @EXPORT = qw(async yield schedule terminate); |
39 | @EXPORT_OK = qw($current); |
39 | @EXPORT_OK = qw($current); |
40 | |
40 | |
41 | { |
41 | { |
… | |
… | |
52 | my @attrs; |
52 | my @attrs; |
53 | for (@_) { |
53 | for (@_) { |
54 | if ($_ eq "Coro") { |
54 | if ($_ eq "Coro") { |
55 | push @async, $ref; |
55 | push @async, $ref; |
56 | } else { |
56 | } else { |
57 | push @attrs, @_; |
57 | push @attrs, $_; |
58 | } |
58 | } |
59 | } |
59 | } |
60 | return $old ? $old->($package, $name, @attrs) : @attrs; |
60 | return $old ? $old->($package, $ref, @attrs) : @attrs; |
61 | }; |
61 | }; |
62 | } |
62 | } |
63 | |
63 | |
64 | sub INIT { |
64 | sub INIT { |
65 | async pop @async while @async; |
65 | async pop @async while @async; |
… | |
… | |
99 | print STDERR "FATAL: deadlock detected\n"; |
99 | print STDERR "FATAL: deadlock detected\n"; |
100 | exit(51); |
100 | exit(51); |
101 | }; |
101 | }; |
102 | |
102 | |
103 | # we really need priorities... |
103 | # we really need priorities... |
104 | ## my @ready; #d# |
|
|
105 | our @ready = (); # the ready queue. hehe, rather broken ;) |
104 | my @ready; # the ready queue. hehe, rather broken ;) |
106 | |
105 | |
107 | # static methods. not really. |
106 | # static methods. not really. |
108 | |
107 | |
109 | =head2 STATIC METHODS |
108 | =head2 STATIC METHODS |
110 | |
109 | |
… | |
… | |
221 | |
220 | |
222 | =cut |
221 | =cut |
223 | |
222 | |
224 | 1; |
223 | 1; |
225 | |
224 | |
226 | =head1 BUGS |
225 | =head1 BUGS/LIMITATIONS |
227 | |
226 | |
228 | - could be faster, especially when the core would introduce special |
227 | - could be faster, especially when the core would introduce special |
229 | support for coroutines (like it does for threads). |
228 | support for coroutines (like it does for threads). |
230 | - there is still a memleak on coroutine termination that I could not |
229 | - there is still a memleak on coroutine termination that I could not |
231 | identify. Could be as small as a single SV. |
230 | identify. Could be as small as a single SV. |
232 | - this module is not well-tested. |
231 | - this module is not well-tested. |
|
|
232 | - if variables or arguments "disappear" (become undef) or become |
|
|
233 | corrupted please contact the author so he cen iron out the |
|
|
234 | remaining bugs. |
|
|
235 | - this module is not thread-safe. You must only ever use this module from |
|
|
236 | the same thread (this requirement might be loosened in the future to |
|
|
237 | allow per-thread schedulers, but Coro::Satte does not yet allow this). |
233 | |
238 | |
234 | =head1 SEE ALSO |
239 | =head1 SEE ALSO |
235 | |
240 | |
236 | L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>, |
241 | L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>, |
237 | L<Coro::Signal>, L<Coro::State>, L<Coro::Event>. |
242 | L<Coro::Signal>, L<Coro::State>, L<Coro::Event>. |