--- Coro/Coro.pm 2004/05/13 16:12:14 1.60 +++ Coro/Coro.pm 2006/11/24 11:36:57 1.81 @@ -32,21 +32,24 @@ package Coro; -BEGIN { eval { require warnings } && warnings->unimport ("uninitialized") } +use strict; +no warnings "uninitialized"; use Coro::State; -use vars qw($idle $main $current); +use base Exporter::; -use base Exporter; +our $idle; # idle coroutine +our $main; # main coroutine +our $current; # current coroutine -$VERSION = 0.96; +our $VERSION = '2.5'; -@EXPORT = qw(async cede schedule terminate current); -%EXPORT_TAGS = ( +our @EXPORT = qw(async cede schedule terminate current); +our %EXPORT_TAGS = ( prio => [qw(PRIO_MAX PRIO_HIGH PRIO_NORMAL PRIO_LOW PRIO_IDLE PRIO_MIN)], ); -@EXPORT_OK = @{$EXPORT_TAGS{prio}}; +our @EXPORT_OK = @{$EXPORT_TAGS{prio}}; { my @async; @@ -54,7 +57,10 @@ # this way of handling attributes simply is NOT scalable ;() sub import { + no strict 'refs'; + Coro->export_to_level(1, @_); + my $old = *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"}{CODE}; *{(caller)[0]."::MODIFY_CODE_ATTRIBUTES"} = sub { my ($package, $ref) = (shift, shift); @@ -159,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"; @@ -225,7 +234,7 @@ sub new { my $class = shift; bless { - _coro_state => (new Coro::State $_[0] && \&_newcoro, @_), + _coro_state => (new Coro::State \&_newcoro, @_), }, $class; } @@ -237,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 @@ -339,14 +348,18 @@ =head1 SEE ALSO -L, L, L, L, -L, L, L, L, -L, Handle>, L. +Support/Utility: L, L, L, L. + +Locking/IPC: L, L, L, L, L. + +Event/IO: L, L, L, L, L. + +Embedding: L =head1 AUTHOR - Marc Lehmann - http://www.goof.com/pcg/marc/ + Marc Lehmann + http://home.schmorp.de/ =cut