--- cvsroot/Coro/Coro.pm 2007/10/06 19:25:00 1.151 +++ cvsroot/Coro/Coro.pm 2007/10/07 13:53:37 1.152 @@ -8,15 +8,22 @@ async { # some asynchronous thread of execution + print "2\n"; + cede; # yield back to main + print "4\n"; }; - - # alternatively create an async coroutine like this: - - sub some_func : Coro { - # some more async code - } - - cede; + print "1\n"; + cede; # yield to coroutine + print "3\n"; + cede; # and again + + # use locking + my $lock = new Coro::Semaphore; + my $locked; + + $lock->down; + $locked = 1; + $lock->up; =head1 DESCRIPTION @@ -35,7 +42,7 @@ In this module, coroutines are defined as "callchain + lexical variables + @_ + $_ + $@ + $/ + C stack), that is, a coroutine has its own callchain, its own set of lexicals and its own set of perls most important global -variables. +variables (see L for more configuration). =cut @@ -52,7 +59,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '4.03'; +our $VERSION = '4.1'; our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); our %EXPORT_TAGS = ( @@ -136,7 +143,7 @@ coroutine so the scheduler can run it. Please note that if your callback recursively invokes perl (e.g. for event -handlers), then it must be prepared to be called recursively. +handlers), then it must be prepared to be called recursively itself. =cut @@ -190,7 +197,7 @@ terminated. See the C constructor for info about the coroutine -environment. +environment in which coroutines run. Calling C in a coroutine will do the same as calling exit outside the coroutine. Likewise, when the coroutine dies, the program will exit, @@ -615,13 +622,19 @@ =head1 SEE ALSO -Support/Utility: L, L, L. +Lower level Configuration, Coroutine Environment: L. + +Debugging: L. + +Support/Utility: L, L. Locking/IPC: L, L, L, L, L. -Event/IO: L, L, L, L, L. +Event/IO: L, L, L, L. + +Compatibility: L, L, L. -Embedding: L +Embedding: L. =head1 AUTHOR