--- cvsroot/Coro/Coro.pm 2007/01/05 17:44:17 1.106 +++ cvsroot/Coro/Coro.pm 2007/03/19 15:50:48 1.118 @@ -52,7 +52,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '3.3'; +our $VERSION = '3.55'; our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); our %EXPORT_TAGS = ( @@ -212,7 +212,10 @@ that might have executed other code already (which can be good or bad :). Also, the block is executed in an C context and a warning will be -issued in case of an exception instead of terminating the program, as C does. +issued in case of an exception instead of terminating the program, as +C does. As the coroutine is being reused, stuff like C +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". @@ -232,9 +235,8 @@ sub pool_handler { while () { - my ($cb, @arg) = @{ delete $current->{_invoke} }; - eval { + my ($cb, @arg) = @{ delete $current->{_invoke} or return }; $cb->(@arg); }; warn $@ if $@; @@ -242,6 +244,7 @@ last if @pool >= $POOL_SIZE; push @pool, $current; + $current->save (Coro::State::SAVE_DEF); $current->prio (0); schedule; } @@ -289,11 +292,15 @@ ready queue and calls C, which has the effect of giving up the current "timeslice" to other coroutines of the same or higher priority. +Returns true if at least one coroutine switch has happened. + =item Coro::cede_notself Works like cede, but is not exported by default and will cede to any coroutine, regardless of priority, once. +Returns true if at least one coroutine switch has happened. + =item terminate [arg...] Terminates the current coroutine with the given status values (see L).