use strict;
use warnings;
use Coro;
use Coro::EV;
use Coro::LWP;
use LWP::Simple;
use Coro::Timer qw(sleep);
async {
while (1) {
CORE::select undef, undef, undef, 0.5;
print "first\n";
# my $r = get "http://www.perlmonks.org";
# print length $r, "\n";
# sleep 0;
cede;
}
};
async {
while (1) {
CORE::select undef, undef, undef, 0.5;
print "second\n";
# sleep 0;
cede;
}
};
EV::loop while 1;
####
first
second
first
second
first
second
...
####
my $r = get "http://www.perlmonks.org";
print length $r, "\n";
####
first
second
second
second
second
second
second
second
####
first
second
76573
second
first
second
76570
second
first
second
76597
second
first
second