… | |
… | |
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 | |
… | |
… | |
971 | poll => 'r', nice => 1, |
972 | poll => 'r', nice => 1, |
972 | cb => &IO::AIO::poll_cb); |
973 | cb => &IO::AIO::poll_cb); |
973 | |
974 | |
974 | =item IO::AIO::poll_wait |
975 | =item IO::AIO::poll_wait |
975 | |
976 | |
|
|
977 | If there are any outstanding requests and none of them in the result |
976 | Wait till the result filehandle becomes ready for reading (simply does a |
978 | phase, wait till the result filehandle becomes ready for reading (simply |
977 | C<select> on the filehandle. This is useful if you want to synchronously |
979 | does a C<select> on the filehandle. This is useful if you want to |
978 | wait for some requests to finish). |
980 | synchronously wait for some requests to finish). |
979 | |
981 | |
980 | See C<nreqs> for an example. |
982 | See C<nreqs> for an example. |
981 | |
983 | |
982 | =item IO::AIO::poll |
984 | =item IO::AIO::poll |
983 | |
985 | |
984 | Waits until some requests have been handled. |
986 | Waits until some requests have been handled. |
985 | |
987 | |
|
|
988 | Returns the number of requests processed, but is otherwise strictly |
986 | Strictly equivalent to: |
989 | equivalent to: |
987 | |
990 | |
988 | IO::AIO::poll_wait, IO::AIO::poll_cb |
991 | IO::AIO::poll_wait, IO::AIO::poll_cb |
989 | if IO::AIO::nreqs; |
|
|
990 | |
992 | |
991 | =item IO::AIO::flush |
993 | =item IO::AIO::flush |
992 | |
994 | |
993 | Wait till all outstanding AIO requests have been handled. |
995 | Wait till all outstanding AIO requests have been handled. |
994 | |
996 | |