--- cvsroot/Coro/Coro.pm 2007/01/12 01:15:03 1.109 +++ cvsroot/Coro/Coro.pm 2007/04/14 15:06:05 1.122 @@ -52,7 +52,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '3.3'; +our $VERSION = '3.56'; our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); our %EXPORT_TAGS = ( @@ -187,10 +187,9 @@ (usually unused). When the sub returns the new coroutine is automatically terminated. -Calling C in a coroutine will not work correctly, so do not do that. - -When the coroutine dies, the program will exit, just as in the main -program. +Calling C in a coroutine will do the same as calling exit outside +the coroutine. Likewise, when the coroutine dies, the program will exit, +just as it would in the main program. # create a new coroutine that just prints its arguments async { @@ -236,7 +235,7 @@ sub pool_handler { while () { eval { - my ($cb, @arg) = @{ delete $current->{_invoke} }; + my ($cb, @arg) = @{ delete $current->{_invoke} or return }; $cb->(@arg); }; warn $@ if $@; @@ -244,6 +243,7 @@ last if @pool >= $POOL_SIZE; push @pool, $current; + $current->save (Coro::State::SAVE_DEF); $current->prio (0); schedule; } @@ -327,7 +327,7 @@ called. To make the coroutine run you must first put it into the ready queue by calling the ready method. -Calling C in a coroutine will not work correctly, so do not do that. +See C for additional discussion. =cut @@ -467,7 +467,7 @@ =item my $guard = Coro::guard { ... } -This creates and returns a guard object. Nothing happens until the objetc +This creates and returns a guard object. Nothing happens until the object gets destroyed, in which case the codeblock given as argument will be executed. This is useful to free locks or other resources in case of a runtime error or when the coroutine gets canceled, as in both cases the