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

Comparing Coro/Coro.pm (file contents):
Revision 1.148 by root, Fri Oct 5 20:11:25 2007 UTC vs.
Revision 1.151 by root, Sat Oct 6 19:25:00 2007 UTC

50 50
51our $idle; # idle handler 51our $idle; # idle handler
52our $main; # main coroutine 52our $main; # main coroutine
53our $current; # current coroutine 53our $current; # current coroutine
54 54
55our $VERSION = '4.01'; 55our $VERSION = '4.03';
56 56
57our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); 57our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub);
58our %EXPORT_TAGS = ( 58our %EXPORT_TAGS = (
59 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], 59 prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)],
60); 60);
255 _pool_2 $cb; 255 _pool_2 $cb;
256 &schedule; 256 &schedule;
257 } 257 }
258 }; 258 };
259 259
260 last if $@ eq "\3terminate\2\n"; 260 last if $@ eq "\3async_pool terminate\2\n";
261 warn $@ if $@; 261 warn $@ if $@;
262 } 262 }
263} 263}
264 264
265sub async_pool(&@) { 265sub async_pool(&@) {
470Sets (or gets in case the argument is missing) the description for this 470Sets (or gets in case the argument is missing) the description for this
471coroutine. This is just a free-form string you can associate with a coroutine. 471coroutine. This is just a free-form string you can associate with a coroutine.
472 472
473This method simply sets the C<< $coroutine->{desc} >> member to the given string. You 473This method simply sets the C<< $coroutine->{desc} >> member to the given string. You
474can modify this member directly if you wish. 474can modify this member directly if you wish.
475
476=item $coroutine->throw ([$scalar])
477
478If C<$throw> is specified and defined, it will be thrown as an exception
479inside the coroutine at the next convinient point in time (usually after
480it gains control at the next schedule/transfer/cede). Otherwise clears the
481exception object.
482
483The exception object will be thrown "as is" with the specified scalar in
484C<$@>, i.e. if it is a string, no line number or newline will be appended
485(unlike with C<die>).
486
487This can be used as a softer means than C<cancel> to ask a coroutine to
488end itself, although there is no guarentee that the exception will lead to
489termination, and if the exception isn't caught it might well end the whole
490program.
475 491
476=cut 492=cut
477 493
478sub desc { 494sub desc {
479 my $old = $_[0]{desc}; 495 my $old = $_[0]{desc};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines