… | |
… | |
275 | Or in other words: the file descriptor will be closed, but it will |
275 | Or in other words: the file descriptor will be closed, but it will |
276 | not be free for reuse until the perl filehandle is closed. |
276 | not be free for reuse until the perl filehandle is closed. |
277 | |
277 | |
278 | aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
278 | aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
279 | aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
279 | aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
280 | Reads or writes $length bytes from the specified $fh and $offset |
280 | Reads or writes $length bytes from or to the specified $fh and |
281 | into the scalar given by $data and offset $dataoffset and calls the |
281 | $offset into the scalar given by $data and offset $dataoffset and |
282 | callback without the actual number of bytes read (or -1 on error, |
282 | calls the callback without the actual number of bytes read (or -1 on |
283 | just like the syscall). |
283 | error, just like the syscall). |
|
|
284 | |
|
|
285 | "aio_read" will, like "sysread", shrink or grow the $data scalar to |
|
|
286 | offset plus the actual number of bytes read. |
284 | |
287 | |
285 | If $offset is undefined, then the current file descriptor offset |
288 | If $offset is undefined, then the current file descriptor offset |
286 | will be used (and updated), otherwise the file descriptor offset |
289 | will be used (and updated), otherwise the file descriptor offset |
287 | will not be changed by these calls. |
290 | will not be changed by these calls. |
288 | |
291 | |
… | |
… | |
465 | aio_move $srcpath, $dstpath, $callback->($status) |
468 | aio_move $srcpath, $dstpath, $callback->($status) |
466 | Try to move the *file* (directories not supported as either source |
469 | Try to move the *file* (directories not supported as either source |
467 | or destination) from $srcpath to $dstpath and call the callback with |
470 | or destination) from $srcpath to $dstpath and call the callback with |
468 | the 0 (error) or -1 ok. |
471 | the 0 (error) or -1 ok. |
469 | |
472 | |
470 | This is a composite request that tries to rename(2) the file first. |
473 | This is a composite request that tries to rename(2) the file first; |
471 | If rename files with "EXDEV", it copies the file with "aio_copy" |
474 | if rename fails with "EXDEV", it copies the file with "aio_copy" |
472 | and, if that is successful, unlinking the $srcpath. |
475 | and, if that is successful, unlinks the $srcpath. |
473 | |
476 | |
474 | aio_scandir $path, $maxreq, $callback->($dirs, $nondirs) |
477 | aio_scandir $path, $maxreq, $callback->($dirs, $nondirs) |
475 | Scans a directory (similar to "aio_readdir") but additionally tries |
478 | Scans a directory (similar to "aio_readdir") but additionally tries |
476 | to efficiently separate the entries of directory $path into two sets |
479 | to efficiently separate the entries of directory $path into two sets |
477 | of names, directories you can recurse into (directories), and ones |
480 | of names, directories you can recurse into (directories), and ones |
… | |
… | |
542 | callback with the fdatasync result code. |
545 | callback with the fdatasync result code. |
543 | |
546 | |
544 | If this call isn't available because your OS lacks it or it couldn't |
547 | If this call isn't available because your OS lacks it or it couldn't |
545 | be detected, it will be emulated by calling "fsync" instead. |
548 | be detected, it will be emulated by calling "fsync" instead. |
546 | |
549 | |
|
|
550 | aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) |
|
|
551 | Sync the data portion of the file specified by $offset and $length |
|
|
552 | to disk (but NOT the metadata), by calling the Linux-specific |
|
|
553 | sync_file_range call. If sync_file_range is not available or it |
|
|
554 | returns ENOSYS, then fdatasync or fsync is being substituted. |
|
|
555 | |
|
|
556 | $flags can be a combination of |
|
|
557 | "IO::AIO::SYNC_FILE_RANGE_WAIT_BEFORE", |
|
|
558 | "IO::AIO::SYNC_FILE_RANGE_WRITE" and |
|
|
559 | "IO::AIO::SYNC_FILE_RANGE_WAIT_AFTER": refer to the sync_file_range |
|
|
560 | manpage for details. |
|
|
561 | |
547 | aio_pathsync $path, $callback->($status) |
562 | aio_pathsync $path, $callback->($status) |
548 | This request tries to open, fsync and close the given path. This is |
563 | This request tries to open, fsync and close the given path. This is |
549 | a composite request intended to sync directories after directory |
564 | a composite request intended to sync directories after directory |
550 | operations (E.g. rename). This might not work on all operating |
565 | operations (E.g. rename). This might not work on all operating |
551 | systems or have any specific effect, but usually it makes sure that |
566 | systems or have any specific effect, but usually it makes sure that |
… | |
… | |
715 | does not impose any limits). |
730 | does not impose any limits). |
716 | |
731 | |
717 | If the feed does not queue more requests when called, it will be |
732 | If the feed does not queue more requests when called, it will be |
718 | automatically removed from the group. |
733 | automatically removed from the group. |
719 | |
734 | |
720 | If the feed limit is 0, it will be set to 2 automatically. |
735 | If the feed limit is 0 when this method is called, it will be set to |
|
|
736 | 2 automatically. |
721 | |
737 | |
722 | Example: |
738 | Example: |
723 | |
739 | |
724 | # stat all files in @files, but only ever use four aio requests concurrently: |
740 | # stat all files in @files, but only ever use four aio requests concurrently: |
725 | |
741 | |
… | |
… | |
735 | limit $grp $num |
751 | limit $grp $num |
736 | Sets the feeder limit for the group: The feeder will be called |
752 | Sets the feeder limit for the group: The feeder will be called |
737 | whenever the group contains less than this many requests. |
753 | whenever the group contains less than this many requests. |
738 | |
754 | |
739 | Setting the limit to 0 will pause the feeding process. |
755 | Setting the limit to 0 will pause the feeding process. |
|
|
756 | |
|
|
757 | The default value for the limit is 0, but note that setting a feeder |
|
|
758 | automatically bumps it up to 2. |
740 | |
759 | |
741 | SUPPORT FUNCTIONS |
760 | SUPPORT FUNCTIONS |
742 | EVENT PROCESSING AND EVENT LOOP INTEGRATION |
761 | EVENT PROCESSING AND EVENT LOOP INTEGRATION |
743 | $fileno = IO::AIO::poll_fileno |
762 | $fileno = IO::AIO::poll_fileno |
744 | Return the *request result pipe file descriptor*. This filehandle |
763 | Return the *request result pipe file descriptor*. This filehandle |