--- cvsroot/Coro/Coro.pm 2003/09/28 09:00:48 1.54 +++ cvsroot/Coro/Coro.pm 2004/02/13 23:17:41 1.58 @@ -32,13 +32,15 @@ package Coro; -no warnings qw(uninitialized); +BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") } use Coro::State; +use vars qw($idle $main $current); + use base Exporter; -$VERSION = 0.7; +$VERSION = 0.95; @EXPORT = qw(async cede schedule terminate current); %EXPORT_TAGS = ( @@ -85,7 +87,7 @@ =cut -our $main = new Coro; +$main = new Coro; =item $current (or as function: current) @@ -98,7 +100,7 @@ $main->{specific} = $current->{specific}; } -our $current = $main; +$current = $main; sub current() { $current } @@ -110,7 +112,7 @@ =cut # should be done using priorities :( -our $idle = new Coro sub { +$idle = new Coro sub { print STDERR "FATAL: deadlock detected\n"; exit(51); }; @@ -120,7 +122,7 @@ my @destroy; my $manager; $manager = new Coro sub { - while() { + while () { # by overwriting the state object with the manager we destroy it # while still being able to schedule this coroutine (in case it has # been readied multiple times. this is harmless since the manager @@ -157,9 +159,6 @@ print "@_\n"; } 1,2,3,4; -The coderef you submit MUST NOT be a closure that refers to variables -in an outer scope. This does NOT work. Pass arguments into it instead. - =cut sub async(&@) {