… | |
… | |
490 | |
490 | |
491 | "S_IFMT", "S_IFIFO", "S_IFCHR", "S_IFBLK", "S_IFLNK", "S_IFREG", |
491 | "S_IFMT", "S_IFIFO", "S_IFCHR", "S_IFBLK", "S_IFLNK", "S_IFREG", |
492 | "S_IFDIR", "S_IFWHT", "S_IFSOCK", "IO::AIO::major $dev_t", |
492 | "S_IFDIR", "S_IFWHT", "S_IFSOCK", "IO::AIO::major $dev_t", |
493 | "IO::AIO::minor $dev_t", "IO::AIO::makedev $major, $minor". |
493 | "IO::AIO::minor $dev_t", "IO::AIO::makedev $major, $minor". |
494 | |
494 | |
|
|
495 | To access higher resolution stat timestamps, see "SUBSECOND STAT |
|
|
496 | TIME ACCESS". |
|
|
497 | |
495 | Example: Print the length of /etc/passwd: |
498 | Example: Print the length of /etc/passwd: |
496 | |
499 | |
497 | aio_stat "/etc/passwd", sub { |
500 | aio_stat "/etc/passwd", sub { |
498 | $_[0] and die "stat failed: $!"; |
501 | $_[0] and die "stat failed: $!"; |
499 | print "size is ", -s _, "\n"; |
502 | print "size is ", -s _, "\n"; |
… | |
… | |
1590 | |
1593 | |
1591 | IO::AIO::npending |
1594 | IO::AIO::npending |
1592 | Returns the number of requests currently in the pending state |
1595 | Returns the number of requests currently in the pending state |
1593 | (executed, but not yet processed by poll_cb). |
1596 | (executed, but not yet processed by poll_cb). |
1594 | |
1597 | |
|
|
1598 | SUBSECOND STAT TIME ACCESS |
|
|
1599 | Both "aio_stat"/"aio_lstat" and perl's "stat"/"lstat" functions can |
|
|
1600 | generally find access/modification and change times with subsecond time |
|
|
1601 | accuracy of the system supports it, but perl's built-in functions only |
|
|
1602 | return the integer part. |
|
|
1603 | |
|
|
1604 | The following functions return the timestamps of the most recent stat |
|
|
1605 | with subsecond precision on most systems and work both after |
|
|
1606 | "aio_stat"/"aio_lstat" and perl's "stat"/"lstat" calls. Their return |
|
|
1607 | value is only meaningful after a successful "stat"/"lstat" call, or |
|
|
1608 | during/after a successful "aio_stat"/"aio_lstat" callback. |
|
|
1609 | |
|
|
1610 | This is similar to the Time::HiRes "stat" functions, but can return full |
|
|
1611 | resolution without rounding and work with standard perl "stat", |
|
|
1612 | alleviating the need to call the special "Time::HiRes" functions, which |
|
|
1613 | do not act like their perl counterparts. |
|
|
1614 | |
|
|
1615 | 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 |
|
|
1617 | returned, so it is always safe to call these functions. |
|
|
1618 | |
|
|
1619 | $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime |
|
|
1620 | Return the access, modication or change time, respectively, |
|
|
1621 | including fractional part. Due to the limited precision of floating |
|
|
1622 | point, the accuracy on most platforms is only a bit better than |
|
|
1623 | milliseconds for times around now - see the *nsec* function family, |
|
|
1624 | below, for full accuracy. |
|
|
1625 | |
|
|
1626 | ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtime |
|
|
1627 | Returns access, modification and change time all in one go, and |
|
|
1628 | maybe more times in the future version. |
|
|
1629 | |
|
|
1630 | $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec, |
|
|
1631 | IO::AIO::st_ctimensec |
|
|
1632 | Return the fractional access, modifcation or change time, in |
|
|
1633 | nanoseconds, as an integer in the range 0 to 999999999. |
|
|
1634 | |
|
|
1635 | ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtimensec |
|
|
1636 | Like the functions above, but returns all three times in one go (and |
|
|
1637 | maybe more in future versions). |
|
|
1638 | |
|
|
1639 | Example: print the high resolution modification time of /etc, using |
|
|
1640 | "stat", and "IO::AIO::aio_stat". |
|
|
1641 | |
|
|
1642 | if (stat "/etc") { |
|
|
1643 | printf "stat(/etc) mtime: %f\n", IO::AIO::st_mtime; |
|
|
1644 | } |
|
|
1645 | |
|
|
1646 | IO::AIO::aio_stat "/etc", sub { |
|
|
1647 | $_[0] |
|
|
1648 | and return; |
|
|
1649 | |
|
|
1650 | printf "aio_stat(/etc) mtime: %d.%09d\n", (stat _)[9], IO::AIO::st_mtimensec; |
|
|
1651 | }; |
|
|
1652 | |
|
|
1653 | IO::AIO::flush; |
|
|
1654 | |
|
|
1655 | Output of the awbove on my system, showing reduced and full accuracy: |
|
|
1656 | |
|
|
1657 | stat(/etc) mtime: 1534043702.020808 |
|
|
1658 | aio_stat(/etc) mtime: 1534043702.020807792 |
|
|
1659 | |
1595 | MISCELLANEOUS FUNCTIONS |
1660 | MISCELLANEOUS FUNCTIONS |
1596 | IO::AIO implements some functions that are useful when you want to use |
1661 | IO::AIO implements some functions that are useful when you want to use |
1597 | some "Advanced I/O" function not available to in Perl, without going the |
1662 | some "Advanced I/O" function not available to in Perl, without going the |
1598 | "Asynchronous I/O" route. Many of these have an asynchronous "aio_*" |
1663 | "Asynchronous I/O" route. Many of these have an asynchronous "aio_*" |
1599 | counterpart. |
1664 | counterpart. |