--- Coro/Coro.pm 2008/01/13 09:47:22 1.167 +++ Coro/Coro.pm 2008/04/19 19:06:02 1.179 @@ -4,26 +4,26 @@ =head1 SYNOPSIS - use Coro; - - async { - # some asynchronous thread of execution - print "2\n"; - cede; # yield back to main - print "4\n"; - }; - 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; + use Coro; + + async { + # some asynchronous thread of execution + print "2\n"; + cede; # yield back to main + print "4\n"; + }; + 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 @@ -59,7 +59,7 @@ our $main; # main coroutine our $current; # current coroutine -our $VERSION = '4.36'; +our $VERSION = '4.51'; our @EXPORT = qw(async async_pool cede schedule terminate current unblock_sub); our %EXPORT_TAGS = ( @@ -67,40 +67,6 @@ ); our @EXPORT_OK = (@{$EXPORT_TAGS{prio}}, qw(nready)); -{ - my @async; - my $init; - - # 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); - my @attrs; - for (@_) { - if ($_ eq "Coro") { - push @async, $ref; - unless ($init++) { - eval q{ - sub INIT { - &async(pop @async) while @async; - } - }; - } - } else { - push @attrs, $_; - } - } - return $old ? $old->($package, $ref, @attrs) : @attrs; - }; - } - -} - =over 4 =item $main @@ -180,8 +146,6 @@ $manager->desc ("[coro manager]"); $manager->prio (PRIO_MAX); -# static methods. not really. - =back =head2 STATIC METHODS @@ -341,8 +305,6 @@ =back -# dynamic methods - =head2 COROUTINE METHODS These are the methods you can call on coroutine objects.