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.63 by root, Mon Mar 4 10:28:38 2019 UTC

469 will be emulated by simply reading the data, which would have a 469 will be emulated by simply reading the data, which would have a
470 similar effect. 470 similar effect.
471 471
472 aio_stat $fh_or_path, $callback->($status) 472 aio_stat $fh_or_path, $callback->($status)
473 aio_lstat $fh, $callback->($status) 473 aio_lstat $fh, $callback->($status)
474 Works like perl's "stat" or "lstat" in void context. The callback 474 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 475 The callback will be called after the stat and the results will be
476 using "stat _" or "-s _" etc... 476 available using "stat _" or "-s _" and other tests (with the
477 exception of "-B" and "-T").
477 478
478 The pathname passed to "aio_stat" must be absolute. See API NOTES, 479 The pathname passed to "aio_stat" must be absolute. See API NOTES,
479 above, for an explanation. 480 above, for an explanation.
480 481
481 Currently, the stats are always 64-bit-stats, i.e. instead of 482 Currently, the stats are always 64-bit-stats, i.e. instead of
548 aio_utime $fh_or_path, $atime, $mtime, $callback->($status) 549 aio_utime $fh_or_path, $atime, $mtime, $callback->($status)
549 Works like perl's "utime" function (including the special case of 550 Works like perl's "utime" function (including the special case of
550 $atime and $mtime being undef). Fractional times are supported if 551 $atime and $mtime being undef). Fractional times are supported if
551 the underlying syscalls support them. 552 the underlying syscalls support them.
552 553
553 When called with a pathname, uses utimes(2) if available, otherwise 554 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 555 available, otherwise utime(2). If called on a file descriptor, uses
555 available, otherwise returns ENOSYS, so this is not portable. 556 futimens(2) or futimes(2) if available, otherwise returns ENOSYS, so
557 this is not portable.
556 558
557 Examples: 559 Examples:
558 560
559 # set atime and mtime to current time (basically touch(1)): 561 # set atime and mtime to current time (basically touch(1)):
560 aio_utime "path", undef, undef; 562 aio_utime "path", undef, undef;
1014 IO::AIO::mmap $data, -s $fh, IO::AIO::PROT_READ, IO::AIO::MAP_SHARED, $fh; 1016 IO::AIO::mmap $data, -s $fh, IO::AIO::PROT_READ, IO::AIO::MAP_SHARED, $fh;
1015 aio_mlock $data; # mlock in background 1017 aio_mlock $data; # mlock in background
1016 1018
1017 aio_mlockall $flags, $callback->($status) 1019 aio_mlockall $flags, $callback->($status)
1018 Calls the "mlockall" function with the given $flags (a combination 1020 Calls the "mlockall" function with the given $flags (a combination
1019 of "IO::AIO::MCL_CURRENT" and "IO::AIO::MCL_FUTURE"). 1021 of "IO::AIO::MCL_CURRENT", "IO::AIO::MCL_FUTURE" and
1022 "IO::AIO::MCL_ONFAULT").
1020 1023
1021 On systems that do not implement "mlockall", this function returns 1024 On systems that do not implement "mlockall", this function returns
1022 -1 and sets errno to "ENOSYS". 1025 -1 and sets errno to "ENOSYS". Similarly, flag combinations not
1026 supported by the system result in a return value of -1 with errno
1027 being set to "EINVAL".
1023 1028
1024 Note that the corresponding "munlockall" is synchronous and is 1029 Note that the corresponding "munlockall" is synchronous and is
1025 documented under "MISCELLANEOUS FUNCTIONS". 1030 documented under "MISCELLANEOUS FUNCTIONS".
1026 1031
1027 Example: asynchronously lock all current and future pages into 1032 Example: asynchronously lock all current and future pages into
1451 Strictly equivalent to: 1456 Strictly equivalent to:
1452 1457
1453 IO::AIO::poll_wait, IO::AIO::poll_cb 1458 IO::AIO::poll_wait, IO::AIO::poll_cb
1454 while IO::AIO::nreqs; 1459 while IO::AIO::nreqs;
1455 1460
1461 This function can be useful at program aborts, to make sure
1462 outstanding I/O has been done ("IO::AIO" uses an "END" block which
1463 already calls this function on normal exits), or when you are merely
1464 using "IO::AIO" for its more advanced functions, rather than for
1465 async I/O, e.g.:
1466
1467 my ($dirs, $nondirs);
1468 IO::AIO::aio_scandir "/tmp", 0, sub { ($dirs, $nondirs) = @_ };
1469 IO::AIO::flush;
1470 # $dirs, $nondirs are now set
1471
1456 IO::AIO::max_poll_reqs $nreqs 1472 IO::AIO::max_poll_reqs $nreqs
1457 IO::AIO::max_poll_time $seconds 1473 IO::AIO::max_poll_time $seconds
1458 These set the maximum number of requests (default 0, meaning 1474 These set the maximum number of requests (default 0, meaning
1459 infinity) that are being processed by "IO::AIO::poll_cb" in one 1475 infinity) that are being processed by "IO::AIO::poll_cb" in one
1460 call, respectively the maximum amount of time (default 0, meaning 1476 call, respectively the maximum amount of time (default 0, meaning
1614 1630
1615 On operating systems or file systems where subsecond time resolution is 1631 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 1632 not supported or could not be detected, a fractional part of 0 is
1617 returned, so it is always safe to call these functions. 1633 returned, so it is always safe to call these functions.
1618 1634
1619 $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime 1635 $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime,
1636 IO::AIO::st_btime
1620 Return the access, modication or change time, respectively, 1637 Return the access, modication, change or birth time, respectively,
1621 including fractional part. Due to the limited precision of floating 1638 including fractional part. Due to the limited precision of floating
1622 point, the accuracy on most platforms is only a bit better than 1639 point, the accuracy on most platforms is only a bit better than
1623 milliseconds for times around now - see the *nsec* function family, 1640 milliseconds for times around now - see the *nsec* function family,
1624 below, for full accuracy. 1641 below, for full accuracy.
1625 1642
1643 File birth time is only available when the OS and perl support it
1644 (on FreeBSD and NetBSD at the time of this writing, although support
1645 is adaptive, so if your OS/perl gains support, IO::AIO can take
1646 avdantage of it). On systems where it isn't available, 0 is
1647 currently returned, but this might change to "undef" in a future
1648 version.
1649
1626 ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtime 1650 ($atime, $mtime, $ctime, $btime, ...) = IO::AIO::st_xtime
1627 Returns access, modification and change time all in one go, and 1651 Returns access, modification, change and birth time all in one go,
1628 maybe more times in the future version. 1652 and maybe more times in the future version.
1629 1653
1630 $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec, 1654 $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec,
1631 IO::AIO::st_ctimensec 1655 IO::AIO::st_ctimensec, IO::AIO::st_btimensec
1632 Return the fractional access, modifcation or change time, in 1656 Return the fractional access, modifcation, change or birth time, in
1633 nanoseconds, as an integer in the range 0 to 999999999. 1657 nanoseconds, as an integer in the range 0 to 999999999.
1634 1658
1659 Note that no accessors are provided for access, modification and
1660 change times - you need to get those from "stat _" if required ("int
1661 IO::AIO::st_atime" and so on will *not* generally give you the
1662 correct value).
1663
1664 $seconds = IO::AIO::st_btimesec
1665 The (integral) seconds part of the file birth time, if available.
1666
1635 ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtimensec 1667 ($atime, $mtime, $ctime, $btime, ...) = IO::AIO::st_xtimensec
1636 Like the functions above, but returns all three times in one go (and 1668 Like the functions above, but returns all four times in one go (and
1637 maybe more in future versions). 1669 maybe more in future versions).
1670
1671 $counter = IO::AIO::st_gen
1672 Returns the generation counter (in practice this is just a random
1673 number) of the file. This is only available on platforms which have
1674 this member in their "struct stat" (most BSDs at the time of this
1675 writing) and generally only to the root usert. If unsupported, 0 is
1676 returned, but this might change to "undef" in a future version.
1638 1677
1639 Example: print the high resolution modification time of /etc, using 1678 Example: print the high resolution modification time of /etc, using
1640 "stat", and "IO::AIO::aio_stat". 1679 "stat", and "IO::AIO::aio_stat".
1641 1680
1642 if (stat "/etc") { 1681 if (stat "/etc") {
1815 version. 1854 version.
1816 1855
1817 On systems where this call is not supported or is not emulated, this 1856 On systems where this call is not supported or is not emulated, this
1818 call returns falls and sets $! to "ENOSYS". 1857 call returns falls and sets $! to "ENOSYS".
1819 1858
1859 IO::AIO::mlockall $flags
1860 Calls the "eio_mlockall_sync" function, which is like
1861 "aio_mlockall", but is blocking.
1862
1820 IO::AIO::munlock $scalar, $offset = 0, $length = undef 1863 IO::AIO::munlock $scalar, $offset = 0, $length = undef
1821 Calls the "munlock" function, undoing the effects of a previous 1864 Calls the "munlock" function, undoing the effects of a previous
1822 "aio_mlock" call (see its description for details). 1865 "aio_mlock" call (see its description for details).
1823 1866
1824 IO::AIO::munlockall 1867 IO::AIO::munlockall

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines