… | |
… | |
424 | than one C<aio_sendfile> per C<$out_fh>, as they will interfere with each |
424 | than one C<aio_sendfile> per C<$out_fh>, as they will interfere with each |
425 | other. |
425 | other. |
426 | |
426 | |
427 | This call tries to make use of a native C<sendfile> syscall to provide |
427 | This call tries to make use of a native C<sendfile> syscall to provide |
428 | zero-copy operation. For this to work, C<$out_fh> should refer to a |
428 | zero-copy operation. For this to work, C<$out_fh> should refer to a |
429 | socket, and C<$in_fh> should refer to mmap'able file. |
429 | socket, and C<$in_fh> should refer to an mmap'able file. |
430 | |
430 | |
431 | If a native sendfile cannot be found or it fails with C<ENOSYS>, |
431 | If a native sendfile cannot be found or it fails with C<ENOSYS>, |
432 | C<ENOTSUP>, C<EOPNOTSUPP>, C<EAFNOSUPPORT>, C<EPROTOTYPE> or C<ENOTSOCK>, |
432 | C<ENOTSUP>, C<EOPNOTSUPP>, C<EAFNOSUPPORT>, C<EPROTOTYPE> or C<ENOTSOCK>, |
433 | it will be emulated, so you can call C<aio_sendfile> on any type of |
433 | it will be emulated, so you can call C<aio_sendfile> on any type of |
434 | filehandle regardless of the limitations of the operating system. |
434 | filehandle regardless of the limitations of the operating system. |
… | |
… | |
1084 | } |
1084 | } |
1085 | |
1085 | |
1086 | =item aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
1086 | =item aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
1087 | |
1087 | |
1088 | This is a rather advanced IO::AIO call, which only works on mmap(2)ed |
1088 | This is a rather advanced IO::AIO call, which only works on mmap(2)ed |
1089 | scalars (see the L<Sys::Mmap> or L<Mmap> modules for details on this, note |
1089 | scalars (see the C<IO::AIO::mmap> function, although it also works on data |
|
|
1090 | scalars managed by the L<Sys::Mmap> or L<Mmap> modules, note that the |
1090 | that the scalar must only be modified in-place while an aio operation is |
1091 | scalar must only be modified in-place while an aio operation is pending on |
1091 | pending on it). |
1092 | it). |
1092 | |
1093 | |
1093 | It calls the C<msync> function of your OS, if available, with the memory |
1094 | It calls the C<msync> function of your OS, if available, with the memory |
1094 | area starting at C<$offset> in the string and ending C<$length> bytes |
1095 | area starting at C<$offset> in the string and ending C<$length> bytes |
1095 | later. If C<$length> is negative, counts from the end, and if C<$length> |
1096 | later. If C<$length> is negative, counts from the end, and if C<$length> |
1096 | is C<undef>, then it goes till the end of the string. The flags can be |
1097 | is C<undef>, then it goes till the end of the string. The flags can be |
… | |
… | |
1544 | C<IO::AIO::FADV_RANDOM>, C<IO::AIO::FADV_NOREUSE>, |
1545 | C<IO::AIO::FADV_RANDOM>, C<IO::AIO::FADV_NOREUSE>, |
1545 | C<IO::AIO::FADV_WILLNEED>, C<IO::AIO::FADV_DONTNEED>. |
1546 | C<IO::AIO::FADV_WILLNEED>, C<IO::AIO::FADV_DONTNEED>. |
1546 | |
1547 | |
1547 | On systems that do not implement C<posix_fadvise>, this function returns |
1548 | On systems that do not implement C<posix_fadvise>, this function returns |
1548 | ENOSYS, otherwise the return value of C<posix_fadvise>. |
1549 | ENOSYS, otherwise the return value of C<posix_fadvise>. |
|
|
1550 | |
|
|
1551 | =item IO::AIO::mmap $scalar, $length, $prot, $flags, $fh[, $offset] |
|
|
1552 | |
|
|
1553 | Memory-maps a file (or anonymous memory range) and attaches it to the |
|
|
1554 | given C<$scalar>, which will act like a string scalar. |
|
|
1555 | |
|
|
1556 | The only operations allowed on the scalar are C<substr>/C<vec> that don't |
|
|
1557 | change the string length, and most read-only operations such as copying it |
|
|
1558 | or searching it with regexes and so on. |
|
|
1559 | |
|
|
1560 | Anything else is unsafe and will, at best, result in memory leaks. |
|
|
1561 | |
|
|
1562 | The memory map associated with the C<$scalar> is automatically removed |
|
|
1563 | when the C<$scalar> is destroyed, or when the C<IO::AIO::mmap> or |
|
|
1564 | C<IO::AIO::munmap> functions are called. |
|
|
1565 | |
|
|
1566 | This calls the C<mmap>(2) function internally. See your system's manual |
|
|
1567 | page for details on the C<$length>, C<$prot> and C<$flags> parameters. |
|
|
1568 | |
|
|
1569 | The C<$length> must be larger than zero and smaller than the actual |
|
|
1570 | filesize. |
|
|
1571 | |
|
|
1572 | C<$prot> is a combination of C<IO::AIO::PROT_NONE>, C<IO::AIO::PROT_EXEC>, |
|
|
1573 | C<IO::AIO::PROT_READ> and/or C<IO::AIO::PROT_WRITE>, |
|
|
1574 | |
|
|
1575 | C<$flags> can be a combination of C<IO::AIO::MAP_SHARED> or |
|
|
1576 | C<IO::AIO::MAP_PRIVATE>, or a number of system-specific flags (when |
|
|
1577 | not available, the are defined as 0): C<IO::AIO::MAP_ANONYMOUS> |
|
|
1578 | (which is set to C<MAP_ANON> if your system only provides this |
|
|
1579 | constant), C<IO::AIO::MAP_HUGETLB>, C<IO::AIO::MAP_LOCKED>, |
|
|
1580 | C<IO::AIO::MAP_NORESERVE>, C<IO::AIO::MAP_POPULATE> or |
|
|
1581 | C<IO::AIO::MAP_NONBLOCK> |
|
|
1582 | |
|
|
1583 | If C<$fh> is C<undef>, then a file descriptor of C<-1> is passed. |
|
|
1584 | |
|
|
1585 | =item IO::AIO::munmap $scalar |
|
|
1586 | |
|
|
1587 | Removes a previous mmap and undefines the C<$scalar>. |
1549 | |
1588 | |
1550 | =item IO::AIO::mlockall $flags |
1589 | =item IO::AIO::mlockall $flags |
1551 | |
1590 | |
1552 | Calls the C<mlockall> function with the given C<$flags> (a combination of |
1591 | Calls the C<mlockall> function with the given C<$flags> (a combination of |
1553 | C<IO::AIO::MCL_CURRENT> and C<IO::AIO::MCL__FUTURE>). |
1592 | C<IO::AIO::MCL_CURRENT> and C<IO::AIO::MCL__FUTURE>). |