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

Comparing Coro/Coro.pm (file contents):
Revision 1.25 by root, Wed Jul 25 21:12:57 2001 UTC vs.
Revision 1.26 by root, Fri Jul 27 02:51:33 2001 UTC

43@EXPORT = qw(async cede schedule terminate current); 43@EXPORT = qw(async cede schedule terminate current);
44@EXPORT_OK = qw($current); 44@EXPORT_OK = qw($current);
45 45
46{ 46{
47 my @async; 47 my @async;
48 my $init;
48 49
49 # this way of handling attributes simply is NOT scalable ;() 50 # this way of handling attributes simply is NOT scalable ;()
50 sub import { 51 sub import {
51 Coro->export_to_level(1, @_); 52 Coro->export_to_level(1, @_);
52 my $old = *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"}{CODE}; 53 my $old = *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"}{CODE};
54 my ($package, $ref) = (shift, shift); 55 my ($package, $ref) = (shift, shift);
55 my @attrs; 56 my @attrs;
56 for (@_) { 57 for (@_) {
57 if ($_ eq "Coro") { 58 if ($_ eq "Coro") {
58 push @async, $ref; 59 push @async, $ref;
60 unless ($init++) {
61 eval q{
62 sub INIT {
63 &async(pop @async) while @async;
64 }
65 };
66 }
59 } else { 67 } else {
60 push @attrs, $_; 68 push @attrs, $_;
61 } 69 }
62 } 70 }
63 return $old ? $old->($package, $ref, @attrs) : @attrs; 71 return $old ? $old->($package, $ref, @attrs) : @attrs;
64 }; 72 };
65 } 73 }
66 74
67 sub INIT {
68 &async(pop @async) while @async;
69 }
70} 75}
71 76
72=item $main 77=item $main
73 78
74This coroutine represents the main program. 79This coroutine represents the main program.
257 262
258=head1 SEE ALSO 263=head1 SEE ALSO
259 264
260L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>, 265L<Coro::Channel>, L<Coro::Cont>, L<Coro::Specific>, L<Coro::Semaphore>,
261L<Coro::Signal>, L<Coro::State>, L<Coro::Event>, L<Coro::RWLock>, 266L<Coro::Signal>, L<Coro::State>, L<Coro::Event>, L<Coro::RWLock>,
262L<Coro::L<Coro::Handle>, L<Coro::Socket>. 267L<Coro::Handle>, L<Coro::Socket>.
263 268
264=head1 AUTHOR 269=head1 AUTHOR
265 270
266 Marc Lehmann <pcg@goof.com> 271 Marc Lehmann <pcg@goof.com>
267 http://www.goof.com/pcg/marc/ 272 http://www.goof.com/pcg/marc/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines