… | |
… | |
186 | |
186 | |
187 | package IO::AIO; |
187 | package IO::AIO; |
188 | |
188 | |
189 | use Carp (); |
189 | use Carp (); |
190 | |
190 | |
191 | no warnings; |
191 | use common::sense; |
192 | use strict 'vars'; |
|
|
193 | |
192 | |
194 | use base 'Exporter'; |
193 | use base 'Exporter'; |
195 | |
194 | |
196 | BEGIN { |
195 | BEGIN { |
197 | our $VERSION = '3.23'; |
196 | our $VERSION = '3.3'; |
198 | |
197 | |
199 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close |
198 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close |
200 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
199 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
201 | aio_scandir aio_symlink aio_readlink aio_sync aio_fsync |
200 | aio_scandir aio_symlink aio_readlink aio_sync aio_fsync |
202 | aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead |
201 | aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead |
… | |
… | |
206 | |
205 | |
207 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); |
206 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); |
208 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
207 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
209 | min_parallel max_parallel max_idle |
208 | min_parallel max_parallel max_idle |
210 | nreqs nready npending nthreads |
209 | nreqs nready npending nthreads |
211 | max_poll_time max_poll_reqs); |
210 | max_poll_time max_poll_reqs |
|
|
211 | sendfile fadvise); |
212 | |
212 | |
213 | push @AIO_REQ, qw(aio_busy); # not exported |
213 | push @AIO_REQ, qw(aio_busy); # not exported |
214 | |
214 | |
215 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
215 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
216 | |
216 | |
… | |
… | |
957 | (E.g. rename). This might not work on all operating systems or have any |
957 | (E.g. rename). This might not work on all operating systems or have any |
958 | specific effect, but usually it makes sure that directory changes get |
958 | specific effect, but usually it makes sure that directory changes get |
959 | written to disc. It works for anything that can be opened for read-only, |
959 | written to disc. It works for anything that can be opened for read-only, |
960 | not just directories. |
960 | not just directories. |
961 | |
961 | |
|
|
962 | Future versions of this function might fall back to other methods when |
|
|
963 | C<fsync> on the directory fails (such as calling C<sync>). |
|
|
964 | |
962 | Passes C<0> when everything went ok, and C<-1> on error. |
965 | Passes C<0> when everything went ok, and C<-1> on error. |
963 | |
966 | |
964 | =cut |
967 | =cut |
965 | |
968 | |
966 | sub aio_pathsync($;$) { |
969 | sub aio_pathsync($;$) { |
… | |
… | |
1394 | Returns the number of requests currently in the pending state (executed, |
1397 | Returns the number of requests currently in the pending state (executed, |
1395 | but not yet processed by poll_cb). |
1398 | but not yet processed by poll_cb). |
1396 | |
1399 | |
1397 | =back |
1400 | =back |
1398 | |
1401 | |
|
|
1402 | =head3 MISCELLANEOUS FUNCTIONS |
|
|
1403 | |
|
|
1404 | IO::AIO implements some functions that might be useful, but are not |
|
|
1405 | asynchronous. |
|
|
1406 | |
|
|
1407 | =over 4 |
|
|
1408 | |
|
|
1409 | =item IO::AIO::sendfile $ofh, $ifh, $offset, $count |
|
|
1410 | |
|
|
1411 | Calls the C<eio_sendfile_sync> function, which is like C<aio_sendfile>, |
|
|
1412 | but is blocking (this makes most sense if you know the input data is |
|
|
1413 | likely cached already and the output filehandle is set to non-blocking |
|
|
1414 | operations). |
|
|
1415 | |
|
|
1416 | Returns the number of bytes copied, or C<-1> on error. |
|
|
1417 | |
|
|
1418 | =item IO::AIO::fadvise $fh, $offset, $len, $advice |
|
|
1419 | |
|
|
1420 | Simply calls the C<posix_fadvise> function (see it's |
|
|
1421 | manpage for details). The following advice constants are |
|
|
1422 | avaiable: C<IO::AIO::FADV_NORMAL>, C<IO::AIO::FADV_SEQUENTIAL>, |
|
|
1423 | C<IO::AIO::FADV_RANDOM>, C<IO::AIO::FADV_NOREUSE>, |
|
|
1424 | C<IO::AIO::FADV_WILLNEED>, C<IO::AIO::FADV_DONTNEED>. |
|
|
1425 | |
|
|
1426 | On systems that do not implement C<posix_fadvise>, this function returns |
|
|
1427 | ENOSYS, otherwise the return value of C<posix_fadvise>. |
|
|
1428 | |
|
|
1429 | =back |
|
|
1430 | |
1399 | =cut |
1431 | =cut |
1400 | |
1432 | |
1401 | min_parallel 8; |
1433 | min_parallel 8; |
1402 | |
1434 | |
1403 | END { flush } |
1435 | END { flush } |