ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.pm
(Generate patch)

Comparing IO-AIO/AIO.pm (file contents):
Revision 1.175 by root, Sun Jan 10 20:37:33 2010 UTC vs.
Revision 1.176 by root, Sun Jan 10 23:05:11 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines