… | |
… | |
561 | |
561 | |
562 | C<S_IFMT>, C<S_IFIFO>, C<S_IFCHR>, C<S_IFBLK>, C<S_IFLNK>, C<S_IFREG>, |
562 | C<S_IFMT>, C<S_IFIFO>, C<S_IFCHR>, C<S_IFBLK>, C<S_IFLNK>, C<S_IFREG>, |
563 | C<S_IFDIR>, C<S_IFWHT>, C<S_IFSOCK>, C<IO::AIO::major $dev_t>, |
563 | C<S_IFDIR>, C<S_IFWHT>, C<S_IFSOCK>, C<IO::AIO::major $dev_t>, |
564 | C<IO::AIO::minor $dev_t>, C<IO::AIO::makedev $major, $minor>. |
564 | C<IO::AIO::minor $dev_t>, C<IO::AIO::makedev $major, $minor>. |
565 | |
565 | |
|
|
566 | To access higher resolution stat timestamps, see L<SUBSECOND STAT TIME |
|
|
567 | ACCESS>. |
|
|
568 | |
566 | Example: Print the length of F</etc/passwd>: |
569 | Example: Print the length of F</etc/passwd>: |
567 | |
570 | |
568 | aio_stat "/etc/passwd", sub { |
571 | aio_stat "/etc/passwd", sub { |
569 | $_[0] and die "stat failed: $!"; |
572 | $_[0] and die "stat failed: $!"; |
570 | print "size is ", -s _, "\n"; |
573 | print "size is ", -s _, "\n"; |
… | |
… | |
2010 | Returns the number of requests currently in the pending state (executed, |
2013 | Returns the number of requests currently in the pending state (executed, |
2011 | but not yet processed by poll_cb). |
2014 | but not yet processed by poll_cb). |
2012 | |
2015 | |
2013 | =back |
2016 | =back |
2014 | |
2017 | |
|
|
2018 | =head3 SUBSECOND STAT TIME ACCESS |
|
|
2019 | |
|
|
2020 | Both C<aio_stat>/C<aio_lstat> and perl's C<stat>/C<lstat> functions can |
|
|
2021 | generally find access/modification and change times with subsecond time |
|
|
2022 | accuracy of the system supports it, but perl's built-in functions only |
|
|
2023 | return the integer part. |
|
|
2024 | |
|
|
2025 | The following functions return the timestamps of the most recent |
|
|
2026 | stat with subsecond precision on most systems and work both after |
|
|
2027 | C<aio_stat>/C<aio_lstat> and perl's C<stat>/C<lstat> calls. Their return |
|
|
2028 | value is only meaningful after a successful C<stat>/C<lstat> call, or |
|
|
2029 | during/after a successful C<aio_stat>/C<aio_lstat> callback. |
|
|
2030 | |
|
|
2031 | This is similar to the L<Time::HiRes> C<stat> functions, but can return |
|
|
2032 | full resolution without rounding and work with standard perl C<stat>, |
|
|
2033 | alleviating the need to call the special C<Time::HiRes> functions, which |
|
|
2034 | do not act like their perl counterparts. |
|
|
2035 | |
|
|
2036 | On operating systems or file systems where subsecond time resolution is |
|
|
2037 | not supported or could not be detected, a fractional part of C<0> is |
|
|
2038 | returned, so it is always safe to call these functions. |
|
|
2039 | |
|
|
2040 | =over 4 |
|
|
2041 | |
|
|
2042 | =item IO::AIO::stat_atime, IO::AIO::stat_mtime, IO::AIO::stat_ctime |
|
|
2043 | |
|
|
2044 | Return the access, modication or change time, respectively, including |
|
|
2045 | fractional part. Due to the limited precision of floating point, the |
|
|
2046 | accuracy on most platforms is only a bit better than milliseconds for |
|
|
2047 | times around now - see the I<nsec> function family, below, for full |
|
|
2048 | accuracy. |
|
|
2049 | |
|
|
2050 | =item ($atime, $mtime, $ctime, ...) = IO::AIO::stat_xtime |
|
|
2051 | |
|
|
2052 | Returns access, modification and change time all in one go, and maybe more |
|
|
2053 | times in the future version. |
|
|
2054 | |
|
|
2055 | =item IO::AIO::stat_atimensec, IO::AIO::stat_mtimensec, IO::AIO::stat_ctimensec |
|
|
2056 | |
|
|
2057 | Return the fractional access, modifcation or change time, in nanoseconds, |
|
|
2058 | as an integer in the range C<0> to C<999999999>. |
|
|
2059 | |
|
|
2060 | =back |
|
|
2061 | |
|
|
2062 | Example: print the high resolution modification time of F</etc>, using |
|
|
2063 | C<stat>, and C<IO::AIO::aio_stat>. |
|
|
2064 | |
|
|
2065 | if (stat "/etc") { |
|
|
2066 | printf "stat(/etc) mtime: %f\n", IO::AIO::stat_mtime; |
|
|
2067 | } |
|
|
2068 | |
|
|
2069 | IO::AIO::aio_stat "/etc", sub { |
|
|
2070 | $_[0] |
|
|
2071 | and return; |
|
|
2072 | |
|
|
2073 | printf "aio_stat(/etc) mtime: %d.%09d\n", (stat _)[9], IO::AIO::stat_mtimensec; |
|
|
2074 | }; |
|
|
2075 | |
|
|
2076 | IO::AIO::flush; |
|
|
2077 | |
|
|
2078 | Output of the awbove on my system, showing reduced and full accuracy: |
|
|
2079 | |
|
|
2080 | stat(/etc) mtime: 1534043702.020808 |
|
|
2081 | aio_stat(/etc) mtime: 1534043702.020807792 |
|
|
2082 | |
2015 | =head3 MISCELLANEOUS FUNCTIONS |
2083 | =head3 MISCELLANEOUS FUNCTIONS |
2016 | |
2084 | |
2017 | IO::AIO implements some functions that are useful when you want to use |
2085 | IO::AIO implements some functions that are useful when you want to use |
2018 | some "Advanced I/O" function not available to in Perl, without going the |
2086 | some "Advanced I/O" function not available to in Perl, without going the |
2019 | "Asynchronous I/O" route. Many of these have an asynchronous C<aio_*> |
2087 | "Asynchronous I/O" route. Many of these have an asynchronous C<aio_*> |