… | |
… | |
171 | use common::sense; |
171 | use common::sense; |
172 | |
172 | |
173 | use base 'Exporter'; |
173 | use base 'Exporter'; |
174 | |
174 | |
175 | BEGIN { |
175 | BEGIN { |
176 | our $VERSION = 4.5; |
176 | our $VERSION = 4.52; |
177 | |
177 | |
178 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
178 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
179 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
179 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
180 | aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl |
180 | aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl |
181 | aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range |
181 | aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range |
… | |
… | |
2037 | not supported or could not be detected, a fractional part of C<0> 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. |
2038 | returned, so it is always safe to call these functions. |
2039 | |
2039 | |
2040 | =over 4 |
2040 | =over 4 |
2041 | |
2041 | |
2042 | =item IO::AIO::stat_atime, IO::AIO::stat_mtime, IO::AIO::stat_ctime |
2042 | =item $seconds = IO::AIO::st_atime, IO::AIO::st_mtime, IO::AIO::st_ctime |
2043 | |
2043 | |
2044 | Return the access, modication or change time, respectively, including |
2044 | Return the access, modication or change time, respectively, including |
2045 | fractional part. Due to the limited precision of floating point, the |
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 |
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 |
2047 | times around now - see the I<nsec> function family, below, for full |
2048 | accuracy. |
2048 | accuracy. |
2049 | |
2049 | |
2050 | =item ($atime, $mtime, $ctime, ...) = IO::AIO::stat_xtime |
2050 | =item ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtime |
2051 | |
2051 | |
2052 | Returns access, modification and change time all in one go, and maybe more |
2052 | Returns access, modification and change time all in one go, and maybe more |
2053 | times in the future version. |
2053 | times in the future version. |
2054 | |
2054 | |
2055 | =item IO::AIO::stat_atimensec, IO::AIO::stat_mtimensec, IO::AIO::stat_ctimensec |
2055 | =item $nanoseconds = IO::AIO::st_atimensec, IO::AIO::st_mtimensec, IO::AIO::st_ctimensec |
2056 | |
2056 | |
2057 | Return the fractional access, modifcation or change time, in nanoseconds, |
2057 | Return the fractional access, modifcation or change time, in nanoseconds, |
2058 | as an integer in the range C<0> to C<999999999>. |
2058 | as an integer in the range C<0> to C<999999999>. |
2059 | |
2059 | |
|
|
2060 | =item ($atime, $mtime, $ctime, ...) = IO::AIO::st_xtimensec |
|
|
2061 | |
|
|
2062 | Like the functions above, but returns all three times in one go (and maybe |
|
|
2063 | more in future versions). |
|
|
2064 | |
2060 | =back |
2065 | =back |
2061 | |
2066 | |
2062 | Example: print the high resolution modification time of F</etc>, using |
2067 | Example: print the high resolution modification time of F</etc>, using |
2063 | C<stat>, and C<IO::AIO::aio_stat>. |
2068 | C<stat>, and C<IO::AIO::aio_stat>. |
2064 | |
2069 | |
2065 | if (stat "/etc") { |
2070 | if (stat "/etc") { |
2066 | printf "stat(/etc) mtime: %f\n", IO::AIO::stat_mtime; |
2071 | printf "stat(/etc) mtime: %f\n", IO::AIO::st_mtime; |
2067 | } |
2072 | } |
2068 | |
2073 | |
2069 | IO::AIO::aio_stat "/etc", sub { |
2074 | IO::AIO::aio_stat "/etc", sub { |
2070 | $_[0] |
2075 | $_[0] |
2071 | and return; |
2076 | and return; |
2072 | |
2077 | |
2073 | printf "aio_stat(/etc) mtime: %d.%09d\n", (stat _)[9], IO::AIO::stat_mtimensec; |
2078 | printf "aio_stat(/etc) mtime: %d.%09d\n", (stat _)[9], IO::AIO::st_mtimensec; |
2074 | }; |
2079 | }; |
2075 | |
2080 | |
2076 | IO::AIO::flush; |
2081 | IO::AIO::flush; |
2077 | |
2082 | |
2078 | Output of the awbove on my system, showing reduced and full accuracy: |
2083 | Output of the awbove on my system, showing reduced and full accuracy: |