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

Comparing Coro/Coro.pm (file contents):
Revision 1.85 by root, Sat Nov 25 00:56:35 2006 UTC vs.
Revision 1.86 by root, Sat Nov 25 01:14:11 2006 UTC

133}; 133};
134 134
135# this coroutine is necessary because a coroutine 135# this coroutine is necessary because a coroutine
136# cannot destroy itself. 136# cannot destroy itself.
137my @destroy; 137my @destroy;
138my $manager;
139$manager = new Coro sub { 138my $manager; $manager = new Coro sub {
140 while () { 139 while () {
141 # by overwriting the state object with the manager we destroy it 140 # by overwriting the state object with the manager we destroy it
142 # while still being able to schedule this coroutine (in case it has 141 # while still being able to schedule this coroutine (in case it has
143 # been readied multiple times. this is harmless since the manager 142 # been readied multiple times. this is harmless since the manager
144 # can be called as many times as neccessary and will always 143 # can be called as many times as neccessary and will always
234by calling the ready method. 233by calling the ready method.
235 234
236=cut 235=cut
237 236
238sub _new_coro { 237sub _new_coro {
239 $current->_clear_idle_sp; # set the idle sp on the following cede 238 $current->_clear_idle_sp; # (re-)set the idle sp on the following cede
240 _set_cede_self; # ensures that cede cede's us first 239 _set_cede_self; # ensures that cede cede's us first
241 cede; 240 cede;
242 terminate &{+shift}; 241 terminate &{+shift};
243} 242}
244 243

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines