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

Comparing Coro/Coro.pm (file contents):
Revision 1.88 by root, Sun Nov 26 02:54:55 2006 UTC vs.
Revision 1.90 by root, Thu Nov 30 18:21:14 2006 UTC

171 171
172Create a new asynchronous process and return it's process object 172Create a new asynchronous process and return it's process object
173(usually unused). When the sub returns the new process is automatically 173(usually unused). When the sub returns the new process is automatically
174terminated. 174terminated.
175 175
176Calling C<exit> in a coroutine will not work correctly, so do not do that.
177
176When the coroutine dies, the program will exit, just as in the main 178When the coroutine dies, the program will exit, just as in the main
177program. 179program.
178 180
179 # create a new coroutine that just prints its arguments 181 # create a new coroutine that just prints its arguments
180 async { 182 async {
230Create a new process and return it. When the sub returns the process 232Create a new process and return it. When the sub returns the process
231automatically terminates as if C<terminate> with the returned values were 233automatically terminates as if C<terminate> with the returned values were
232called. To make the process run you must first put it into the ready queue 234called. To make the process run you must first put it into the ready queue
233by calling the ready method. 235by calling the ready method.
234 236
237Calling C<exit> in a coroutine will not work correctly, so do not do that.
238
235=cut 239=cut
236 240
237sub _new_coro { 241sub _new_coro {
238 terminate &{+shift}; 242 terminate &{+shift};
239} 243}
242 my $class = shift; 246 my $class = shift;
243 247
244 $class->SUPER::new (\&_new_coro, @_) 248 $class->SUPER::new (\&_new_coro, @_)
245} 249}
246 250
247=item $process->ready 251=item $success = $process->ready
248 252
249Put the given process into the ready queue. 253Put the given process into the ready queue (according to it's priority)
254and return true. If the process is already in the ready queue, do nothing
255and return false.
250 256
251=cut 257=item $is_ready = $process->is_ready
258
259Return wether the process is currently the ready queue or not,
252 260
253=item $process->cancel (arg...) 261=item $process->cancel (arg...)
254 262
255Terminates the given process and makes it return the given arguments as 263Terminates the given process and makes it return the given arguments as
256status (default: the empty list). 264status (default: the empty list).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines