--- Coro/Coro.pm 2008/10/04 23:26:30 1.204 +++ Coro/Coro.pm 2008/11/05 15:38:10 1.209 @@ -69,7 +69,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = 4.8; +our $VERSION = 4.804; our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); our %EXPORT_TAGS = ( @@ -170,7 +170,7 @@ &schedule; } }; -$manager->desc ("[coro manager]"); +$manager->{desc} = "[coro manager]"; $manager->prio (PRIO_MAX); =back @@ -443,6 +443,25 @@ } } +=item $coroutine->throw ([$scalar]) + +If C<$throw> is specified and defined, it will be thrown as an exception +inside the coroutine at the next convenient point in time (usually after +it gains control at the next schedule/transfer/cede). Otherwise clears the +exception object. + +The exception object will be thrown "as is" with the specified scalar in +C<$@>, i.e. if it is a string, no line number or newline will be appended +(unlike with C). + +This can be used as a softer means than C to ask a coroutine to +end itself, although there is no guarantee that the exception will lead to +termination, and if the exception isn't caught it might well end the whole +program. + +You might also think of C as being the moral equivalent of +Cing a coroutine with a signal (in this case, a scalar). + =item $coroutine->join Wait until the coroutine terminates and return any values given to the @@ -513,26 +532,11 @@ =item $olddesc = $coroutine->desc ($newdesc) Sets (or gets in case the argument is missing) the description for this -coroutine. This is just a free-form string you can associate with a coroutine. - -This method simply sets the C<< $coroutine->{desc} >> member to the given string. You -can modify this member directly if you wish. - -=item $coroutine->throw ([$scalar]) - -If C<$throw> is specified and defined, it will be thrown as an exception -inside the coroutine at the next convinient point in time (usually after -it gains control at the next schedule/transfer/cede). Otherwise clears the -exception object. - -The exception object will be thrown "as is" with the specified scalar in -C<$@>, i.e. if it is a string, no line number or newline will be appended -(unlike with C). +coroutine. This is just a free-form string you can associate with a +coroutine. -This can be used as a softer means than C to ask a coroutine to -end itself, although there is no guarentee that the exception will lead to -termination, and if the exception isn't caught it might well end the whole -program. +This method simply sets the C<< $coroutine->{desc} >> member to the given +string. You can modify this member directly if you wish. =cut @@ -644,7 +648,7 @@ schedule; # sleep well } }; -$unblock_scheduler->desc ("[unblock_sub scheduler]"); +$unblock_scheduler->{desc} = "[unblock_sub scheduler]"; sub unblock_sub(&) { my $cb = shift;