… | |
… | |
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 | |
976 | If there are any outstanding requests, wait till the result filehandle |
977 | If there are any outstanding requests and none of them in the result |
977 | becomes ready for reading (simply does a C<select> on the filehandle. This |
978 | phase, wait till the result filehandle becomes ready for reading (simply |
|
|
979 | does a C<select> on the filehandle. This is useful if you want to |
978 | is useful if you want to synchronously 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 | |
… | |
… | |
985 | |
987 | |
986 | Returns the number of requests processed, but is otherwise strictly |
988 | Returns the number of requests processed, but is otherwise strictly |
987 | equivalent to: |
989 | equivalent to: |
988 | |
990 | |
989 | IO::AIO::poll_wait, IO::AIO::poll_cb |
991 | IO::AIO::poll_wait, IO::AIO::poll_cb |
990 | if IO::AIO::nreqs; |
|
|
991 | |
992 | |
992 | =item IO::AIO::flush |
993 | =item IO::AIO::flush |
993 | |
994 | |
994 | Wait till all outstanding AIO requests have been handled. |
995 | Wait till all outstanding AIO requests have been handled. |
995 | |
996 | |