--- Coro/Coro.pm 2001/07/03 02:53:34 1.1 +++ Coro/Coro.pm 2001/07/03 03:40:07 1.2 @@ -6,8 +6,30 @@ use Coro; + $new = new Coro sub { + print "in coroutine, switching back\n"; + $Coro::main->resume; + print "in coroutine again, switching back\n"; + $Coro::main->resume; + }; + + print "in main, switching to coroutine\n"; + $new->resume; + print "back in main, switch to coroutine again\n"; + $new->resume; + print "back in main\n"; + =head1 DESCRIPTION +This module implements coroutines. Coroutines, similar to continuations, +allow you to run more than one "thread of execution" in parallel. Unlike +threads this, only voluntary switching is used so locking problems are +greatly reduced. + +Although this is the "main" module of the Coro family it provides only +low-level functionality. See L and related modules for a +more useful process abstraction including scheduling. + =over 4 =cut @@ -47,7 +69,7 @@ $error_coro = undef; $error = _newprocess { - print STDERR "FATAL: $error_msg, program aborted\n"; + print STDERR "FATAL: $error_msg\nprogram aborted\n"; exit 250; }; @@ -95,6 +117,10 @@ This module has not yet been extensively tested. +=head1 SEE ALSO + +L, L. + =head1 AUTHOR Marc Lehmann