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

Comparing Coro/Coro.pm (file contents):
Revision 1.227 by root, Thu Nov 20 03:10:30 2008 UTC vs.
Revision 1.229 by root, Thu Nov 20 06:32:55 2008 UTC

212Similar to C<async>, but uses a coroutine pool, so you should not call 212Similar to C<async>, but uses a coroutine pool, so you should not call
213terminate or join on it (although you are allowed to), and you get a 213terminate or join on it (although you are allowed to), and you get a
214coroutine that might have executed other code already (which can be good 214coroutine that might have executed other code already (which can be good
215or bad :). 215or bad :).
216 216
217On the plus side, this function is faster than creating (and destroying) 217On the plus side, this function is about twice as fast as creating (and
218a completly new coroutine, so if you need a lot of generic coroutines in 218destroying) a completely new coroutine, so if you need a lot of generic
219quick successsion, use C<async_pool>, not C<async>. 219coroutines in quick successsion, use C<async_pool>, not C<async>.
220 220
221The code block is executed in an C<eval> context and a warning will be 221The code block is executed in an C<eval> context and a warning will be
222issued in case of an exception instead of terminating the program, as 222issued in case of an exception instead of terminating the program, as
223C<async> does. As the coroutine is being reused, stuff like C<on_destroy> 223C<async> does. As the coroutine is being reused, stuff like C<on_destroy>
224will not work in the expected way, unless you call terminate or cancel, 224will not work in the expected way, unless you call terminate or cancel,
390 } else { 390 } else {
391 $self->{_status} = [@_]; 391 $self->{_status} = [@_];
392 $self->_cancel; 392 $self->_cancel;
393 } 393 }
394} 394}
395
396=item $coroutine->schedule_to
397
398Puts the current coroutine to sleep (like C<Coro::schedule>), but instead
399of continuing with the next coro from the ready queue, always switch to
400the given coroutine object (regardless of priority etc.). The readyness
401state of that coroutine isn't changed.
402
403This is an advanced method for special cases - I'd love to hear about any
404uses for this one.
405
406=item $coroutine->cede_to
407
408Like C<schedule_to>, but puts the current coroutine into the ready
409queue. This has the effect of temporarily switching to the given
410coroutine, and continuing some time later.
411
412This is an advanced method for special cases - I'd love to hear about any
413uses for this one.
395 414
396=item $coroutine->throw ([$scalar]) 415=item $coroutine->throw ([$scalar])
397 416
398If C<$throw> is specified and defined, it will be thrown as an exception 417If C<$throw> is specified and defined, it will be thrown as an exception
399inside the coroutine at the next convenient point in time. Otherwise 418inside the coroutine at the next convenient point in time. Otherwise

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines