ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro.pm
(Generate patch)

Comparing Coro/Coro.pm (file contents):
Revision 1.16 by root, Tue Jul 17 15:42:28 2001 UTC vs.
Revision 1.19 by root, Sat Jul 21 03:44:06 2001 UTC

31 31
32use Coro::State; 32use Coro::State;
33 33
34use base Exporter; 34use base Exporter;
35 35
36$VERSION = 0.07; 36$VERSION = 0.09;
37 37
38@EXPORT = qw(async yield schedule terminate); 38@EXPORT = qw(async yield schedule terminate current);
39@EXPORT_OK = qw($current); 39@EXPORT_OK = qw($current);
40 40
41{ 41{
42 use subs 'async'; 42 use subs 'async';
43 43
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;
72 72
73=cut 73=cut
74 74
75our $main = new Coro; 75our $main = new Coro;
76 76
77=item $current 77=item $current (or as function: current)
78 78
79The current coroutine (the last coroutine switched to). The initial value is C<$main> (of course). 79The current coroutine (the last coroutine switched to). The initial value is C<$main> (of course).
80 80
81=cut 81=cut
82 82
84if ($current) { 84if ($current) {
85 $main->{specific} = $current->{specific}; 85 $main->{specific} = $current->{specific};
86} 86}
87 87
88our $current = $main; 88our $current = $main;
89
90sub current() { $current }
89 91
90=item $idle 92=item $idle
91 93
92The coroutine to switch to when no other coroutine is running. The default 94The coroutine to switch to when no other coroutine is running. The default
93implementation prints "FATAL: deadlock detected" and exits. 95implementation prints "FATAL: deadlock detected" and exits.
220 222
221=cut 223=cut
222 224
2231; 2251;
224 226
225=head1 BUGS 227=head1 BUGS/LIMITATIONS
226 228
227 - could be faster, especially when the core would introduce special 229 - could be faster, especially when the core would introduce special
228 support for coroutines (like it does for threads). 230 support for coroutines (like it does for threads).
229 - there is still a memleak on coroutine termination that I could not 231 - there is still a memleak on coroutine termination that I could not
230 identify. Could be as small as a single SV. 232 identify. Could be as small as a single SV.
231 - this module is not well-tested. 233 - this module is not well-tested.
234 - if variables or arguments "disappear" (become undef) or become
235 corrupted please contact the author so he cen iron out the
236 remaining bugs.
237 - this module is not thread-safe. You must only ever use this module from
238 the same thread (this requirement might be loosened in the future to
239 allow per-thread schedulers, but Coro::Satte does not yet allow this).
232 240
233=head1 SEE ALSO 241=head1 SEE ALSO
234 242
235L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>, 243L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>,
236L<Coro::Signal>, L<Coro::State>, L<Coro::Event>. 244L<Coro::Signal>, L<Coro::State>, L<Coro::Event>.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines