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

Comparing IO-AIO/README (file contents):
Revision 1.61 by root, Sun Aug 12 06:07:06 2018 UTC vs.
Revision 1.64 by root, Wed Apr 3 03:03:53 2019 UTC

221 IO::AIO::idle_timeout $seconds 221 IO::AIO::idle_timeout $seconds
222 IO::AIO::max_outstanding $maxreqs 222 IO::AIO::max_outstanding $maxreqs
223 IO::AIO::nreqs 223 IO::AIO::nreqs
224 IO::AIO::nready 224 IO::AIO::nready
225 IO::AIO::npending 225 IO::AIO::npending
226 IO::AIO::reinit
227
226 $nfd = IO::AIO::get_fdlimit [EXPERIMENTAL] 228 $nfd = IO::AIO::get_fdlimit [EXPERIMENTAL]
227 IO::AIO::min_fdlimit $nfd [EXPERIMENTAL] 229 IO::AIO::min_fdlimit $nfd [EXPERIMENTAL]
228 230
229 IO::AIO::sendfile $ofh, $ifh, $offset, $count 231 IO::AIO::sendfile $ofh, $ifh, $offset, $count
230 IO::AIO::fadvise $fh, $offset, $len, $advice 232 IO::AIO::fadvise $fh, $offset, $len, $advice
233
231 IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] 234 IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]]
232 IO::AIO::munmap $scalar 235 IO::AIO::munmap $scalar
233 IO::AIO::mremap $scalar, $new_length, $flags[, $new_address] 236 IO::AIO::mremap $scalar, $new_length, $flags[, $new_address]
234 IO::AIO::madvise $scalar, $offset, $length, $advice 237 IO::AIO::madvise $scalar, $offset, $length, $advice
235 IO::AIO::mprotect $scalar, $offset, $length, $protect 238 IO::AIO::mprotect $scalar, $offset, $length, $protect
236 IO::AIO::munlock $scalar, $offset = 0, $length = undef 239 IO::AIO::munlock $scalar, $offset = 0, $length = undef
237 IO::AIO::munlockall 240 IO::AIO::munlockall
241
242 # stat extensions
243 $counter = IO::AIO::st_gen
244 $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime, IO::AIO::st_btime
245 ($atime, $mtime, $ctime, $btime, ...) = IO::AIO::st_xtime
246 $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec, IO::AIO::st_ctimensec, IO::AIO::st_btimensec
247 $seconds = IO::AIO::st_btimesec
248 ($atime, $mtime, $ctime, $btime, ...) = IO::AIO::st_xtimensec
249
250 # very much unportable syscalls
251 IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags
252 IO::AIO::tee $r_fh, $w_fh, $length, $flags
253 $actual_size = IO::AIO::pipesize $r_fh[, $new_size]
254 ($rfh, $wfh) = IO::AIO::pipe2 [$flags]
255 $fh = IO::AIO::memfd_create $pathname[, $flags]
256 $fh = IO::AIO::eventfd [$initval, [$flags]]
257 $fh = IO::AIO::timerfd_create $clockid[, $flags]
258 ($cur_interval, $cur_value) = IO::AIO::timerfd_settime $fh, $flags, $new_interval, $nbw_value
259 ($cur_interval, $cur_value) = IO::AIO::timerfd_gettime $fh
238 260
239 API NOTES 261 API NOTES
240 All the "aio_*" calls are more or less thin wrappers around the syscall 262 All the "aio_*" calls are more or less thin wrappers around the syscall
241 with the same name (sans "aio_"). The arguments are similar or 263 with the same name (sans "aio_"). The arguments are similar or
242 identical, and they all accept an additional (and optional) $callback 264 identical, and they all accept an additional (and optional) $callback
469 will be emulated by simply reading the data, which would have a 491 will be emulated by simply reading the data, which would have a
470 similar effect. 492 similar effect.
471 493
472 aio_stat $fh_or_path, $callback->($status) 494 aio_stat $fh_or_path, $callback->($status)
473 aio_lstat $fh, $callback->($status) 495 aio_lstat $fh, $callback->($status)
474 Works like perl's "stat" or "lstat" in void context. The callback 496 Works almost exactly like perl's "stat" or "lstat" in void context.
475 will be called after the stat and the results will be available 497 The callback will be called after the stat and the results will be
476 using "stat _" or "-s _" etc... 498 available using "stat _" or "-s _" and other tests (with the
499 exception of "-B" and "-T").
477 500
478 The pathname passed to "aio_stat" must be absolute. See API NOTES, 501 The pathname passed to "aio_stat" must be absolute. See API NOTES,
479 above, for an explanation. 502 above, for an explanation.
480 503
481 Currently, the stats are always 64-bit-stats, i.e. instead of 504 Currently, the stats are always 64-bit-stats, i.e. instead of
548 aio_utime $fh_or_path, $atime, $mtime, $callback->($status) 571 aio_utime $fh_or_path, $atime, $mtime, $callback->($status)
549 Works like perl's "utime" function (including the special case of 572 Works like perl's "utime" function (including the special case of
550 $atime and $mtime being undef). Fractional times are supported if 573 $atime and $mtime being undef). Fractional times are supported if
551 the underlying syscalls support them. 574 the underlying syscalls support them.
552 575
553 When called with a pathname, uses utimes(2) if available, otherwise 576 When called with a pathname, uses utimensat(2) or utimes(2) if
554 utime(2). If called on a file descriptor, uses futimes(2) if 577 available, otherwise utime(2). If called on a file descriptor, uses
555 available, otherwise returns ENOSYS, so this is not portable. 578 futimens(2) or futimes(2) if available, otherwise returns ENOSYS, so
579 this is not portable.
556 580
557 Examples: 581 Examples:
558 582
559 # set atime and mtime to current time (basically touch(1)): 583 # set atime and mtime to current time (basically touch(1)):
560 aio_utime "path", undef, undef; 584 aio_utime "path", undef, undef;
1014 IO::AIO::mmap $data, -s $fh, IO::AIO::PROT_READ, IO::AIO::MAP_SHARED, $fh; 1038 IO::AIO::mmap $data, -s $fh, IO::AIO::PROT_READ, IO::AIO::MAP_SHARED, $fh;
1015 aio_mlock $data; # mlock in background 1039 aio_mlock $data; # mlock in background
1016 1040
1017 aio_mlockall $flags, $callback->($status) 1041 aio_mlockall $flags, $callback->($status)
1018 Calls the "mlockall" function with the given $flags (a combination 1042 Calls the "mlockall" function with the given $flags (a combination
1019 of "IO::AIO::MCL_CURRENT" and "IO::AIO::MCL_FUTURE"). 1043 of "IO::AIO::MCL_CURRENT", "IO::AIO::MCL_FUTURE" and
1044 "IO::AIO::MCL_ONFAULT").
1020 1045
1021 On systems that do not implement "mlockall", this function returns 1046 On systems that do not implement "mlockall", this function returns
1022 -1 and sets errno to "ENOSYS". 1047 -1 and sets errno to "ENOSYS". Similarly, flag combinations not
1048 supported by the system result in a return value of -1 with errno
1049 being set to "EINVAL".
1023 1050
1024 Note that the corresponding "munlockall" is synchronous and is 1051 Note that the corresponding "munlockall" is synchronous and is
1025 documented under "MISCELLANEOUS FUNCTIONS". 1052 documented under "MISCELLANEOUS FUNCTIONS".
1026 1053
1027 Example: asynchronously lock all current and future pages into 1054 Example: asynchronously lock all current and future pages into
1451 Strictly equivalent to: 1478 Strictly equivalent to:
1452 1479
1453 IO::AIO::poll_wait, IO::AIO::poll_cb 1480 IO::AIO::poll_wait, IO::AIO::poll_cb
1454 while IO::AIO::nreqs; 1481 while IO::AIO::nreqs;
1455 1482
1483 This function can be useful at program aborts, to make sure
1484 outstanding I/O has been done ("IO::AIO" uses an "END" block which
1485 already calls this function on normal exits), or when you are merely
1486 using "IO::AIO" for its more advanced functions, rather than for
1487 async I/O, e.g.:
1488
1489 my ($dirs, $nondirs);
1490 IO::AIO::aio_scandir "/tmp", 0, sub { ($dirs, $nondirs) = @_ };
1491 IO::AIO::flush;
1492 # $dirs, $nondirs are now set
1493
1456 IO::AIO::max_poll_reqs $nreqs 1494 IO::AIO::max_poll_reqs $nreqs
1457 IO::AIO::max_poll_time $seconds 1495 IO::AIO::max_poll_time $seconds
1458 These set the maximum number of requests (default 0, meaning 1496 These set the maximum number of requests (default 0, meaning
1459 infinity) that are being processed by "IO::AIO::poll_cb" in one 1497 infinity) that are being processed by "IO::AIO::poll_cb" in one
1460 call, respectively the maximum amount of time (default 0, meaning 1498 call, respectively the maximum amount of time (default 0, meaning
1614 1652
1615 On operating systems or file systems where subsecond time resolution is 1653 On operating systems or file systems where subsecond time resolution is
1616 not supported or could not be detected, a fractional part of 0 is 1654 not supported or could not be detected, a fractional part of 0 is
1617 returned, so it is always safe to call these functions. 1655 returned, so it is always safe to call these functions.
1618 1656
1619 $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime 1657 $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime,
1658 IO::AIO::st_btime
1620 Return the access, modication or change time, respectively, 1659 Return the access, modication, change or birth time, respectively,
1621 including fractional part. Due to the limited precision of floating 1660 including fractional part. Due to the limited precision of floating
1622 point, the accuracy on most platforms is only a bit better than 1661 point, the accuracy on most platforms is only a bit better than
1623 milliseconds for times around now - see the *nsec* function family, 1662 milliseconds for times around now - see the *nsec* function family,
1624 below, for full accuracy. 1663 below, for full accuracy.
1625 1664
1665 File birth time is only available when the OS and perl support it
1666 (on FreeBSD and NetBSD at the time of this writing, although support
1667 is adaptive, so if your OS/perl gains support, IO::AIO can take
1668 advantage of it). On systems where it isn't available, 0 is
1669 currently returned, but this might change to "undef" in a future
1670 version.
1671
1626 ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtime 1672 ($atime, $mtime, $ctime, $btime, ...) = IO::AIO::st_xtime
1627 Returns access, modification and change time all in one go, and 1673 Returns access, modification, change and birth time all in one go,
1628 maybe more times in the future version. 1674 and maybe more times in the future version.
1629 1675
1630 $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec, 1676 $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec,
1631 IO::AIO::st_ctimensec 1677 IO::AIO::st_ctimensec, IO::AIO::st_btimensec
1632 Return the fractional access, modifcation or change time, in 1678 Return the fractional access, modifcation, change or birth time, in
1633 nanoseconds, as an integer in the range 0 to 999999999. 1679 nanoseconds, as an integer in the range 0 to 999999999.
1634 1680
1681 Note that no accessors are provided for access, modification and
1682 change times - you need to get those from "stat _" if required ("int
1683 IO::AIO::st_atime" and so on will *not* generally give you the
1684 correct value).
1685
1686 $seconds = IO::AIO::st_btimesec
1687 The (integral) seconds part of the file birth time, if available.
1688
1635 ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtimensec 1689 ($atime, $mtime, $ctime, $btime, ...) = IO::AIO::st_xtimensec
1636 Like the functions above, but returns all three times in one go (and 1690 Like the functions above, but returns all four times in one go (and
1637 maybe more in future versions). 1691 maybe more in future versions).
1692
1693 $counter = IO::AIO::st_gen
1694 Returns the generation counter (in practice this is just a random
1695 number) of the file. This is only available on platforms which have
1696 this member in their "struct stat" (most BSDs at the time of this
1697 writing) and generally only to the root usert. If unsupported, 0 is
1698 returned, but this might change to "undef" in a future version.
1638 1699
1639 Example: print the high resolution modification time of /etc, using 1700 Example: print the high resolution modification time of /etc, using
1640 "stat", and "IO::AIO::aio_stat". 1701 "stat", and "IO::AIO::aio_stat".
1641 1702
1642 if (stat "/etc") { 1703 if (stat "/etc") {
1815 version. 1876 version.
1816 1877
1817 On systems where this call is not supported or is not emulated, this 1878 On systems where this call is not supported or is not emulated, this
1818 call returns falls and sets $! to "ENOSYS". 1879 call returns falls and sets $! to "ENOSYS".
1819 1880
1881 IO::AIO::mlockall $flags
1882 Calls the "eio_mlockall_sync" function, which is like
1883 "aio_mlockall", but is blocking.
1884
1820 IO::AIO::munlock $scalar, $offset = 0, $length = undef 1885 IO::AIO::munlock $scalar, $offset = 0, $length = undef
1821 Calls the "munlock" function, undoing the effects of a previous 1886 Calls the "munlock" function, undoing the effects of a previous
1822 "aio_mlock" call (see its description for details). 1887 "aio_mlock" call (see its description for details).
1823 1888
1824 IO::AIO::munlockall 1889 IO::AIO::munlockall
1874 Example: create a pipe race-free w.r.t. threads and fork: 1939 Example: create a pipe race-free w.r.t. threads and fork:
1875 1940
1876 my ($rfh, $wfh) = IO::AIO::pipe2 IO::AIO::O_CLOEXEC 1941 my ($rfh, $wfh) = IO::AIO::pipe2 IO::AIO::O_CLOEXEC
1877 or die "pipe2: $!\n"; 1942 or die "pipe2: $!\n";
1878 1943
1944 $fh = IO::AIO::memfd_create $pathname[, $flags]
1945 This is a direct interface to the Linux memfd_create(2) system call.
1946 The (unhelpful) default for $flags is 0, but your default should be
1947 "IO::AIO::MFD_CLOEXEC".
1948
1949 On success, the new memfd filehandle is returned, otherwise returns
1950 "undef". If the memfd_create syscall is missing, fails with
1951 "ENOSYS".
1952
1953 Please refer to memfd_create(2) for more info on this call.
1954
1955 The following $flags values are available: "IO::AIO::MFD_CLOEXEC",
1956 "IO::AIO::MFD_ALLOW_SEALING" and "IO::AIO::MFD_HUGETLB".
1957
1958 Example: create a new memfd.
1959
1960 my $fh = IO::AIO::memfd_create "somenameforprocfd", IO::AIO::MFD_CLOEXEC
1961 or die "m,emfd_create: $!\n";
1879 $fh = IO::AIO::eventfd [$initval, [$flags]] 1962 =item $fh = IO::AIO::eventfd [$initval, [$flags]]
1963
1880 This is a direct interface to the Linux eventfd(2) system call. The 1964 This is a direct interface to the Linux eventfd(2) system call. The
1881 (unhelpful) defaults for $initval and $flags are 0 for both. 1965 (unhelpful) defaults for $initval and $flags are 0 for both.
1882 1966
1883 On success, the new eventfd filehandle is returned, otherwise 1967 On success, the new eventfd filehandle is returned, otherwise
1884 returns "undef". If the eventfd syscall is missing, fails with 1968 returns "undef". If the eventfd syscall is missing, fails with
1890 "IO::AIO::EFD_CLOEXEC", "IO::AIO::EFD_NONBLOCK" and 1974 "IO::AIO::EFD_CLOEXEC", "IO::AIO::EFD_NONBLOCK" and
1891 "IO::AIO::EFD_SEMAPHORE" (Linux 2.6.30). 1975 "IO::AIO::EFD_SEMAPHORE" (Linux 2.6.30).
1892 1976
1893 Example: create a new eventfd filehandle: 1977 Example: create a new eventfd filehandle:
1894 1978
1895 $fh = IO::AIO::eventfd 0, IO::AIO::O_CLOEXEC 1979 $fh = IO::AIO::eventfd 0, IO::AIO::EFD_CLOEXEC
1896 or die "eventfd: $!\n"; 1980 or die "eventfd: $!\n";
1897 1981
1898 $fh = IO::AIO::timerfd_create $clockid[, $flags] 1982 $fh = IO::AIO::timerfd_create $clockid[, $flags]
1899 This is a direct interface to the Linux timerfd_create(2) system 1983 This is a direct interface to the Linux timerfd_create(2) system
1900 call. The (unhelpful) default for $flags is 0. 1984 call. The (unhelpful) default for $flags is 0, but your default
1985 should be "IO::AIO::TFD_CLOEXEC".
1901 1986
1902 On success, the new timerfd filehandle is returned, otherwise 1987 On success, the new timerfd filehandle is returned, otherwise
1903 returns "undef". If the eventfd syscall is missing, fails with 1988 returns "undef". If the timerfd_create syscall is missing, fails
1904 "ENOSYS". 1989 with "ENOSYS".
1905 1990
1906 Please refer to timerfd_create(2) for more info on this call. 1991 Please refer to timerfd_create(2) for more info on this call.
1907 1992
1908 The following $clockid values are available: 1993 The following $clockid values are available:
1909 "IO::AIO::CLOCK_REALTIME", "IO::AIO::CLOCK_MONOTONIC" 1994 "IO::AIO::CLOCK_REALTIME", "IO::AIO::CLOCK_MONOTONIC"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines