--- Coro/Coro.pm 2003/05/27 00:26:34 1.52 +++ Coro/Coro.pm 2003/11/30 22:49:25 1.57 @@ -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.652; +$VERSION = "0.9"; @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(&@) { @@ -328,8 +327,7 @@ =head1 BUGS/LIMITATIONS - you must make very sure that no coro is still active on global - destruction. very bad things might happen otherwise (usually segfaults - or "panic: top_env"). + destruction. very bad things might happen otherwise (usually segfaults). - this module is not thread-safe. You should only ever use this module from the same thread (this requirement might be losened in the future @@ -339,8 +337,8 @@ =head1 SEE ALSO L, L, L, L, -L, L, L, L, -L, L. +L, L, L, L, +L, Handle>, L. =head1 AUTHOR