--- Coro/Coro.pm 2007/10/03 16:03:17 1.145 +++ Coro/Coro.pm 2007/10/06 19:25:00 1.151 @@ -52,7 +52,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '4.0'; +our $VERSION = '4.03'; our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); our %EXPORT_TAGS = ( @@ -221,8 +221,12 @@ will not work in the expected way, unless you call terminate or cancel, which somehow defeats the purpose of pooling. -The priority will be reset to C<0> after each job, otherwise the coroutine -will be re-used "as-is". +The priority will be reset to C<0> after each job, tracing will be +disabled, the description will be reset and the default output filehandle +gets restored, so you can change alkl these. Otherwise the coroutine will +be re-used "as-is": most notably if you change other per-coroutine global +stuff such as C<$/> you need to revert that change, which is most simply +done by using local as in C< local $/ >. The pool size is limited to 8 idle coroutines (this can be adjusted by changing $Coro::POOL_SIZE), and there can be as many non-idle coros as @@ -253,7 +257,7 @@ } }; - last if $@ eq "\3terminate\2\n"; + last if $@ eq "\3async_pool terminate\2\n"; warn $@ if $@; } } @@ -469,6 +473,22 @@ 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). + +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. + =cut sub desc { @@ -595,7 +615,7 @@ =head1 SEE ALSO -Support/Utility: L, L, L, L. +Support/Utility: L, L, L. Locking/IPC: L, L, L, L, L.