--- Coro/Coro.pm 2007/01/05 16:55:01 1.105 +++ Coro/Coro.pm 2007/02/28 11:43:03 1.115 @@ -52,7 +52,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '3.3'; +our $VERSION = '3.501'; 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 $@; @@ -244,8 +246,8 @@ $current->prio (0); schedule; - } -} + } +} sub async_pool(&@) { # this is also inlined into the unlock_scheduler @@ -289,11 +291,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).