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

Comparing Coro/Coro.pm (file contents):
Revision 1.35 by root, Mon Sep 24 00:16:30 2001 UTC vs.
Revision 1.37 by root, Mon Sep 24 02:25:44 2001 UTC

31important global variables. 31important global variables.
32 32
33=cut 33=cut
34 34
35package Coro; 35package Coro;
36
37no warnings qw(uninitialized);
36 38
37use Coro::State; 39use Coro::State;
38 40
39use base Exporter; 41use base Exporter;
40 42
116# this coroutine is necessary because a coroutine 118# this coroutine is necessary because a coroutine
117# cannot destroy itself. 119# cannot destroy itself.
118my @destroy; 120my @destroy;
119my $manager = new Coro sub { 121my $manager = new Coro sub {
120 while() { 122 while() {
121 delete ((pop @destroy)->{_coro_state}) while @destroy; 123 # by overwriting the state object with the manager we destroy it
124 # while still being able to schedule this coroutine (in case it has
125 # been readied multiple times. this is harmless since the manager
126 # can be called as many times as neccessary and will always
127 # remove itself from the runqueue
128 (pop @destroy)->{_coro_state} = $manager->{_coro_state} while @destroy;
122 &schedule; 129 &schedule;
123 } 130 }
124}; 131};
125 132
126# static methods. not really. 133# static methods. not really.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines