… | |
… | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use IO::AIO; |
7 | use IO::AIO; |
8 | |
8 | |
9 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
9 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
10 | my ($fh) = @_; |
10 | my $fh = shift |
|
|
11 | or die "/etc/passwd: $!"; |
11 | ... |
12 | ... |
12 | }; |
13 | }; |
13 | |
14 | |
14 | aio_unlink "/tmp/file", sub { }; |
15 | aio_unlink "/tmp/file", sub { }; |
15 | |
16 | |
… | |
… | |
99 | poll => 'r', |
100 | poll => 'r', |
100 | cb => \&IO::AIO::poll_cb); |
101 | cb => \&IO::AIO::poll_cb); |
101 | |
102 | |
102 | # queue the request to open /etc/passwd |
103 | # queue the request to open /etc/passwd |
103 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
104 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
104 | my $fh = $_[0] |
105 | my $fh = shift |
105 | or die "error while opening: $!"; |
106 | or die "error while opening: $!"; |
106 | |
107 | |
107 | # stat'ing filehandles is generally non-blocking |
108 | # stat'ing filehandles is generally non-blocking |
108 | my $size = -s $fh; |
109 | my $size = -s $fh; |
109 | |
110 | |