… | |
… | |
168 | use common::sense; |
168 | use common::sense; |
169 | |
169 | |
170 | use base 'Exporter'; |
170 | use base 'Exporter'; |
171 | |
171 | |
172 | BEGIN { |
172 | BEGIN { |
173 | our $VERSION = '3.72'; |
173 | our $VERSION = '3.9'; |
174 | |
174 | |
175 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close |
175 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close |
176 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
176 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
177 | aio_scandir aio_symlink aio_readlink aio_sync aio_fsync |
177 | aio_scandir aio_symlink aio_readlink aio_sync aio_fsync |
178 | aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead |
178 | aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead |
… | |
… | |
368 | } else { |
368 | } else { |
369 | die "open failed: $!\n"; |
369 | die "open failed: $!\n"; |
370 | } |
370 | } |
371 | }; |
371 | }; |
372 | |
372 | |
|
|
373 | In addition to all the common open modes/flags (C<O_RDONLY>, C<O_WRONLY>, |
|
|
374 | C<O_RDWR>, C<O_CREAT>, C<O_TRUNC>, C<O_EXCL> and C<O_APPEND>), the |
|
|
375 | following POSIX and non-POSIX constants are available (missing ones on |
|
|
376 | your system are, as usual, C<0>): |
|
|
377 | |
|
|
378 | C<O_ASYNC>, C<O_DIRECT>, C<O_NOATIME>, C<O_CLOEXEC>, C<O_NOCTTY>, C<O_NOFOLLOW>, |
|
|
379 | C<O_NONBLOCK>, C<O_EXEC>, C<O_SEARCH>, C<O_DIRECTORY>, C<O_DSYNC>, |
|
|
380 | C<O_RSYNC>, C<O_SYNC> and C<O_TTY_INIT>. |
|
|
381 | |
373 | |
382 | |
374 | =item aio_close $fh, $callback->($status) |
383 | =item aio_close $fh, $callback->($status) |
375 | |
384 | |
376 | Asynchronously close a file and call the callback with the result |
385 | Asynchronously close a file and call the callback with the result |
377 | code. |
386 | code. |
… | |
… | |
668 | |
677 | |
669 | =over 4 |
678 | =over 4 |
670 | |
679 | |
671 | =item IO::AIO::READDIR_DENTS |
680 | =item IO::AIO::READDIR_DENTS |
672 | |
681 | |
673 | When this flag is off, then the callback gets an arrayref with of names |
682 | When this flag is off, then the callback gets an arrayref consisting of |
674 | only (as with C<aio_readdir>), otherwise it gets an arrayref with |
683 | names only (as with C<aio_readdir>), otherwise it gets an arrayref with |
675 | C<[$name, $type, $inode]> arrayrefs, each describing a single directory |
684 | C<[$name, $type, $inode]> arrayrefs, each describing a single directory |
676 | entry in more detail. |
685 | entry in more detail. |
677 | |
686 | |
678 | C<$name> is the name of the entry. |
687 | C<$name> is the name of the entry. |
679 | |
688 | |
… | |
… | |
692 | systems that do not deliver the inode information. |
701 | systems that do not deliver the inode information. |
693 | |
702 | |
694 | =item IO::AIO::READDIR_DIRS_FIRST |
703 | =item IO::AIO::READDIR_DIRS_FIRST |
695 | |
704 | |
696 | When this flag is set, then the names will be returned in an order where |
705 | When this flag is set, then the names will be returned in an order where |
697 | likely directories come first. This is useful when you need to quickly |
706 | likely directories come first, in optimal stat order. This is useful when |
698 | find directories, or you want to find all directories while avoiding to |
707 | you need to quickly find directories, or you want to find all directories |
699 | stat() each entry. |
708 | while avoiding to stat() each entry. |
700 | |
709 | |
701 | If the system returns type information in readdir, then this is used |
710 | If the system returns type information in readdir, then this is used |
702 | to find directories directly. Otherwise, likely directories are files |
711 | to find directories directly. Otherwise, likely directories are names |
703 | beginning with ".", or otherwise files with no dots, of which files with |
712 | beginning with ".", or otherwise names with no dots, of which names with |
704 | short names are tried first. |
713 | short names are tried first. |
705 | |
714 | |
706 | =item IO::AIO::READDIR_STAT_ORDER |
715 | =item IO::AIO::READDIR_STAT_ORDER |
707 | |
716 | |
708 | When this flag is set, then the names will be returned in an order |
717 | When this flag is set, then the names will be returned in an order |
… | |
… | |
1406 | |
1415 | |
1407 | See C<poll_cb> for an example. |
1416 | See C<poll_cb> for an example. |
1408 | |
1417 | |
1409 | =item IO::AIO::poll_cb |
1418 | =item IO::AIO::poll_cb |
1410 | |
1419 | |
1411 | Process some outstanding events on the result pipe. You have to call this |
1420 | Process some outstanding events on the result pipe. You have to call |
1412 | regularly. Returns C<0> if all events could be processed, or C<-1> if it |
1421 | this regularly. Returns C<0> if all events could be processed (or there |
1413 | returned earlier for whatever reason. Returns immediately when no events |
1422 | were no events to process), or C<-1> if it returned earlier for whatever |
1414 | are outstanding. The amount of events processed depends on the settings of |
1423 | reason. Returns immediately when no events are outstanding. The amount of |
1415 | C<IO::AIO::max_poll_req> and C<IO::AIO::max_poll_time>. |
1424 | events processed depends on the settings of C<IO::AIO::max_poll_req> and |
|
|
1425 | C<IO::AIO::max_poll_time>. |
1416 | |
1426 | |
1417 | If not all requests were processed for whatever reason, the filehandle |
1427 | If not all requests were processed for whatever reason, the filehandle |
1418 | will still be ready when C<poll_cb> returns, so normally you don't have to |
1428 | will still be ready when C<poll_cb> returns, so normally you don't have to |
1419 | do anything special to have it called later. |
1429 | do anything special to have it called later. |
|
|
1430 | |
|
|
1431 | Apart from calling C<IO::AIO::poll_cb> when the event filehandle becomes |
|
|
1432 | ready, it can be beneficial to call this function from loops which submit |
|
|
1433 | a lot of requests, to make sure the results get processed when they become |
|
|
1434 | available and not just when the loop is finished and the event loop takes |
|
|
1435 | over again. This function returns very fast when there are no outstanding |
|
|
1436 | requests. |
1420 | |
1437 | |
1421 | Example: Install an Event watcher that automatically calls |
1438 | Example: Install an Event watcher that automatically calls |
1422 | IO::AIO::poll_cb with high priority (more examples can be found in the |
1439 | IO::AIO::poll_cb with high priority (more examples can be found in the |
1423 | SYNOPSIS section, at the top of this document): |
1440 | SYNOPSIS section, at the top of this document): |
1424 | |
1441 | |