--- Coro/Coro.pm 2006/01/25 21:43:58 1.75 +++ Coro/Coro.pm 2006/11/24 13:40:36 1.82 @@ -43,7 +43,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = 1.8; +our $VERSION = '2.5'; our @EXPORT = qw(async cede schedule terminate current); our %EXPORT_TAGS = ( @@ -143,7 +143,7 @@ # process itself intact (we basically make it a zombie # process that always runs the manager thread, so it's possible # to transfer() to this process). - $coro->{_coro_state} = $manager->{_coro_state}; + $coro->{_coro_state}->_clone_state_from ($manager->{_coro_state}); } &schedule; } @@ -165,6 +165,9 @@ (usually unused). When the sub returns the new process is automatically terminated. +When the coroutine dies, the program will exit, just as in the main +program. + # create a new coroutine that just prints its arguments async { print "@_\n"; @@ -231,7 +234,7 @@ sub new { my $class = shift; bless { - _coro_state => (new Coro::State $_[0] && \&_newcoro, @_), + _coro_state => (new Coro::State \&_newcoro, @_), }, $class; } @@ -243,7 +246,7 @@ =item $process->cancel (arg...) -Temrinates the given process and makes it return the given arguments as +Terminates the given process and makes it return the given arguments as status (default: the empty list). =cut @@ -273,7 +276,7 @@ wantarray ? @{$self->{status}} : $self->{status}[0]; } -=item $oldprio = $process->prio($newprio) +=item $oldprio = $process->prio ($newprio) Sets (or gets, if the argument is missing) the priority of the process. Higher priority processes get run before lower priority @@ -298,12 +301,10 @@ =cut sub prio { - my $old = $_[0]{prio}; - $_[0]{prio} = $_[1] if @_ > 1; - $old; + shift->{_coro_state}->prio (@_) } -=item $newprio = $process->nice($change) +=item $newprio = $process->nice ($change) Similar to C, but subtract the given value from the priority (i.e. higher values mean lower priority, just as in unix). @@ -311,10 +312,10 @@ =cut sub nice { - $_[0]{prio} -= $_[1]; + shift->{_coro_state}->nice (@_) } -=item $olddesc = $process->desc($newdesc) +=item $olddesc = $process->desc ($newdesc) Sets (or gets in case the argument is missing) the description for this process. This is just a free-form string you can associate with a process.