… | |
… | |
37 | use base 'Exporter'; |
37 | use base 'Exporter'; |
38 | |
38 | |
39 | our @EXPORT = qw(gethostbyname gethostbyaddr); |
39 | our @EXPORT = qw(gethostbyname gethostbyaddr); |
40 | our @EXPORT_OK = qw(inet_aton fork_eval); |
40 | our @EXPORT_OK = qw(inet_aton fork_eval); |
41 | |
41 | |
42 | our $VERSION = 5.162; |
42 | our $VERSION = 5.17; |
43 | |
43 | |
44 | our $MAXPARALLEL = 16; # max. number of parallel jobs |
44 | our $MAXPARALLEL = 16; # max. number of parallel jobs |
45 | |
45 | |
46 | my $jobs = new Coro::Semaphore $MAXPARALLEL; |
46 | my $jobs = new Coro::Semaphore $MAXPARALLEL; |
47 | |
47 | |
… | |
… | |
59 | Coro::State::_exit 0; |
59 | Coro::State::_exit 0; |
60 | } |
60 | } |
61 | |
61 | |
62 | my $buf; |
62 | my $buf; |
63 | my $wakeup = Coro::rouse_cb; |
63 | my $wakeup = Coro::rouse_cb; |
64 | my $w; $w = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { |
64 | my $w; $w = AE::io $fh, 0, sub { |
65 | sysread $fh, $buf, 16384, length $buf |
65 | sysread $fh, $buf, 16384, length $buf |
66 | and return; |
66 | and return; |
67 | |
67 | |
68 | undef $w; |
68 | undef $w; |
69 | $wakeup->(); |
69 | $wakeup->(); |
70 | }); |
70 | }; |
71 | |
71 | |
72 | Coro::rouse_wait; |
72 | Coro::rouse_wait; |
73 | |
73 | |
74 | $jobs->up; |
74 | $jobs->up; |
75 | my @r = map { pack "H*", $_ } split /\0/, $buf; |
75 | my @r = map { pack "H*", $_ } split /\0/, $buf; |