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

Comparing Coro/Coro.pm (file contents):
Revision 1.29 by root, Sat Aug 11 00:37:31 2001 UTC vs.
Revision 1.30 by root, Sat Aug 11 19:59:19 2001 UTC

118 delete ((pop @destroy)->{_coro_state}) while @destroy; 118 delete ((pop @destroy)->{_coro_state}) while @destroy;
119 &schedule; 119 &schedule;
120 } 120 }
121}; 121};
122 122
123# we really need priorities...
124my @ready; # the ready queue. hehe, rather broken ;)
125
126# static methods. not really. 123# static methods. not really.
127 124
128=head2 STATIC METHODS 125=head2 STATIC METHODS
129 126
130Static methods are actually functions that operate on the current process only. 127Static methods are actually functions that operate on the current process only.
160into the ready queue, so calling this function usually means you will 157into the ready queue, so calling this function usually means you will
161never be called again. 158never be called again.
162 159
163=cut 160=cut
164 161
165my $prev;
166
167sub schedule {
168 # should be done using priorities :(
169 ($prev, $current) = ($current, shift @ready || $idle);
170 Coro::State::transfer($prev, $current);
171}
172
173=item cede 162=item cede
174 163
175"Cede" to other processes. This function puts the current process into the 164"Cede" to other processes. This function puts the current process into the
176ready queue and calls C<schedule>, which has the effect of giving up the 165ready queue and calls C<schedule>, which has the effect of giving up the
177current "timeslice" to other coroutines of the same or higher priority. 166current "timeslice" to other coroutines of the same or higher priority.
178 167
179=cut 168=cut
180
181sub cede {
182 $current->ready;
183 &schedule;
184}
185 169
186=item terminate 170=item terminate
187 171
188Terminates the current process. 172Terminates the current process.
189 173
232=item $process->ready 216=item $process->ready
233 217
234Put the current process into the ready queue. 218Put the current process into the ready queue.
235 219
236=cut 220=cut
237
238sub ready {
239 push @ready, $_[0];
240}
241 221
242=item $process->cancel 222=item $process->cancel
243 223
244Like C<terminate>, but terminates the specified process instead. 224Like C<terminate>, but terminates the specified process instead.
245 225

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines