--- cvsroot/Coro/Coro.pm 2006/11/24 15:34:33 1.83 +++ cvsroot/Coro/Coro.pm 2006/11/27 02:01:33 1.89 @@ -43,7 +43,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '2.5'; +our $VERSION = '3.0'; our @EXPORT = qw(async cede schedule terminate current); our %EXPORT_TAGS = ( @@ -135,8 +135,7 @@ # this coroutine is necessary because a coroutine # cannot destroy itself. my @destroy; -my $manager; -$manager = new Coro sub { +my $manager; $manager = new Coro sub { while () { # by overwriting the state object with the manager we destroy it # while still being able to schedule this coroutine (in case it has @@ -174,6 +173,8 @@ (usually unused). When the sub returns the new process 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. @@ -186,9 +187,8 @@ sub async(&@) { my $pid = new Coro @_; - $manager->ready; # this ensures that the stack is cloned from the manager $pid->ready; - $pid; + $pid } =item schedule @@ -234,16 +234,18 @@ called. To make the process 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. + =cut -sub _newcoro { +sub _new_coro { terminate &{+shift}; } sub new { my $class = shift; - $class->SUPER::new (\&_newcoro, @_) + $class->SUPER::new (\&_new_coro, @_) } =item $process->ready