… | |
… | |
692 | the callback. If an error occurs, nothing or undef gets passed to |
692 | the callback. If an error occurs, nothing or undef gets passed to |
693 | the callback. |
693 | the callback. |
694 | |
694 | |
695 | aio_realpath $pathname, $callback->($path) |
695 | aio_realpath $pathname, $callback->($path) |
696 | Asynchronously make the path absolute and resolve any symlinks in |
696 | Asynchronously make the path absolute and resolve any symlinks in |
697 | $path. The resulting path only consists of directories (Same as |
697 | $path. The resulting path only consists of directories (same as |
698 | Cwd::realpath). |
698 | Cwd::realpath). |
699 | |
699 | |
700 | This request can be used to get the absolute path of the current |
700 | This request can be used to get the absolute path of the current |
701 | working directory by passing it a path of . (a single dot). |
701 | working directory by passing it a path of . (a single dot). |
702 | |
702 | |
703 | aio_rename $srcpath, $dstpath, $callback->($status) |
703 | aio_rename $srcpath, $dstpath, $callback->($status) |
704 | Asynchronously rename the object at $srcpath to $dstpath, just as |
704 | Asynchronously rename the object at $srcpath to $dstpath, just as |
705 | rename(2) and call the callback with the result code. |
705 | rename(2) and call the callback with the result code. |
|
|
706 | |
|
|
707 | On systems that support the AIO::WD working directory abstraction |
|
|
708 | natively, the case "[$wd, "."]" as $srcpath is specialcased - |
|
|
709 | instead of failing, "rename" is called on the absolute path of $wd. |
706 | |
710 | |
707 | aio_mkdir $pathname, $mode, $callback->($status) |
711 | aio_mkdir $pathname, $mode, $callback->($status) |
708 | Asynchronously mkdir (create) a directory and call the callback with |
712 | Asynchronously mkdir (create) a directory and call the callback with |
709 | the result code. $mode will be modified by the umask at the time the |
713 | the result code. $mode will be modified by the umask at the time the |
710 | request is executed, so do not change your umask. |
714 | request is executed, so do not change your umask. |
711 | |
715 | |
712 | aio_rmdir $pathname, $callback->($status) |
716 | aio_rmdir $pathname, $callback->($status) |
713 | Asynchronously rmdir (delete) a directory and call the callback with |
717 | Asynchronously rmdir (delete) a directory and call the callback with |
714 | the result code. |
718 | the result code. |
|
|
719 | |
|
|
720 | On systems that support the AIO::WD working directory abstraction |
|
|
721 | natively, the case "[$wd, "."]" is specialcased - instead of |
|
|
722 | failing, "rmdir" is called on the absolute path of $wd. |
715 | |
723 | |
716 | aio_readdir $pathname, $callback->($entries) |
724 | aio_readdir $pathname, $callback->($entries) |
717 | Unlike the POSIX call of the same name, "aio_readdir" reads an |
725 | Unlike the POSIX call of the same name, "aio_readdir" reads an |
718 | entire directory (i.e. opendir + readdir + closedir). The entries |
726 | entire directory (i.e. opendir + readdir + closedir). The entries |
719 | will not be sorted, and will NOT include the "." and ".." entries. |
727 | will not be sorted, and will NOT include the "." and ".." entries. |
… | |
… | |
942 | |
950 | |
943 | It touches (reads or writes) all memory pages in the specified range |
951 | It touches (reads or writes) all memory pages in the specified range |
944 | inside the scalar. All caveats and parameters are the same as for |
952 | inside the scalar. All caveats and parameters are the same as for |
945 | "aio_msync", above, except for flags, which must be either 0 (which |
953 | "aio_msync", above, except for flags, which must be either 0 (which |
946 | reads all pages and ensures they are instantiated) or |
954 | reads all pages and ensures they are instantiated) or |
947 | "IO::AIO::MT_MODIFY", which modifies the memory page s(by reading |
955 | "IO::AIO::MT_MODIFY", which modifies the memory pages (by reading |
948 | and writing an octet from it, which dirties the page). |
956 | and writing an octet from it, which dirties the page). |
949 | |
957 | |
950 | aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) |
958 | aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) |
951 | This is a rather advanced IO::AIO call, which works best on |
959 | This is a rather advanced IO::AIO call, which works best on |
952 | mmap(2)ed scalars. |
960 | mmap(2)ed scalars. |
… | |
… | |
1153 | will still point to the original directory. Most functions accepting a |
1161 | will still point to the original directory. Most functions accepting a |
1154 | pathname will use the directory fd on newer systems, and the string on |
1162 | pathname will use the directory fd on newer systems, and the string on |
1155 | older systems. Some functions (such as realpath) will always rely on the |
1163 | older systems. Some functions (such as realpath) will always rely on the |
1156 | string form of the pathname. |
1164 | string form of the pathname. |
1157 | |
1165 | |
1158 | So this fucntionality is mainly useful to get some protection against |
1166 | So this functionality is mainly useful to get some protection against |
1159 | "chdir", to easily get an absolute path out of a relative path for |
1167 | "chdir", to easily get an absolute path out of a relative path for |
1160 | future reference, and to speed up doing many operations in the same |
1168 | future reference, and to speed up doing many operations in the same |
1161 | directory (e.g. when stat'ing all files in a directory). |
1169 | directory (e.g. when stat'ing all files in a directory). |
1162 | |
1170 | |
1163 | The following functions implement this working directory abstraction: |
1171 | The following functions implement this working directory abstraction: |
… | |
… | |
1182 | This is a compiletime constant (object) that represents the process |
1190 | This is a compiletime constant (object) that represents the process |
1183 | current working directory. |
1191 | current working directory. |
1184 | |
1192 | |
1185 | Specifying this object as working directory object for a pathname is |
1193 | Specifying this object as working directory object for a pathname is |
1186 | as if the pathname would be specified directly, without a directory |
1194 | as if the pathname would be specified directly, without a directory |
1187 | object, e.g., these calls are functionally identical: |
1195 | object. For example, these calls are functionally identical: |
1188 | |
1196 | |
1189 | aio_stat "somefile", sub { ... }; |
1197 | aio_stat "somefile", sub { ... }; |
1190 | aio_stat [IO::AIO::CWD, "somefile"], sub { ... }; |
1198 | aio_stat [IO::AIO::CWD, "somefile"], sub { ... }; |
|
|
1199 | |
|
|
1200 | To recover the path associated with an IO::AIO::WD object, you can use |
|
|
1201 | "aio_realpath": |
|
|
1202 | |
|
|
1203 | aio_realpath $wd, sub { |
|
|
1204 | warn "path is $_[0]\n"; |
|
|
1205 | }; |
|
|
1206 | |
|
|
1207 | Currently, "aio_statvfs" always, and "aio_rename" and "aio_rmdir" |
|
|
1208 | sometimes, fall back to using an absolue path. |
1191 | |
1209 | |
1192 | IO::AIO::REQ CLASS |
1210 | IO::AIO::REQ CLASS |
1193 | All non-aggregate "aio_*" functions return an object of this class when |
1211 | All non-aggregate "aio_*" functions return an object of this class when |
1194 | called in non-void context. |
1212 | called in non-void context. |
1195 | |
1213 | |
… | |
… | |
1347 | results. |
1365 | results. |
1348 | |
1366 | |
1349 | See "poll_cb" for an example. |
1367 | See "poll_cb" for an example. |
1350 | |
1368 | |
1351 | IO::AIO::poll_cb |
1369 | IO::AIO::poll_cb |
1352 | Process some outstanding events on the result pipe. You have to call |
1370 | Process some requests that have reached the result phase (i.e. they |
|
|
1371 | have been executed but the results are not yet reported). You have |
|
|
1372 | to call this "regularly" to finish outstanding requests. |
|
|
1373 | |
1353 | this regularly. Returns 0 if all events could be processed (or there |
1374 | Returns 0 if all events could be processed (or there were no events |
1354 | were no events to process), or -1 if it returned earlier for |
1375 | to process), or -1 if it returned earlier for whatever reason. |
1355 | whatever reason. Returns immediately when no events are outstanding. |
1376 | Returns immediately when no events are outstanding. The amount of |
1356 | The amount of events processed depends on the settings of |
1377 | events processed depends on the settings of "IO::AIO::max_poll_req", |
1357 | "IO::AIO::max_poll_req" and "IO::AIO::max_poll_time". |
1378 | "IO::AIO::max_poll_time" and "IO::AIO::max_outstanding". |
1358 | |
1379 | |
1359 | If not all requests were processed for whatever reason, the |
1380 | If not all requests were processed for whatever reason, the poll |
1360 | filehandle will still be ready when "poll_cb" returns, so normally |
1381 | file descriptor will still be ready when "poll_cb" returns, so |
1361 | you don't have to do anything special to have it called later. |
1382 | normally you don't have to do anything special to have it called |
|
|
1383 | later. |
1362 | |
1384 | |
1363 | Apart from calling "IO::AIO::poll_cb" when the event filehandle |
1385 | Apart from calling "IO::AIO::poll_cb" when the event filehandle |
1364 | becomes ready, it can be beneficial to call this function from loops |
1386 | becomes ready, it can be beneficial to call this function from loops |
1365 | which submit a lot of requests, to make sure the results get |
1387 | which submit a lot of requests, to make sure the results get |
1366 | processed when they become available and not just when the loop is |
1388 | processed when they become available and not just when the loop is |
… | |
… | |
1374 | Event->io (fd => IO::AIO::poll_fileno, |
1396 | Event->io (fd => IO::AIO::poll_fileno, |
1375 | poll => 'r', async => 1, |
1397 | poll => 'r', async => 1, |
1376 | cb => \&IO::AIO::poll_cb); |
1398 | cb => \&IO::AIO::poll_cb); |
1377 | |
1399 | |
1378 | IO::AIO::poll_wait |
1400 | IO::AIO::poll_wait |
1379 | If there are any outstanding requests and none of them in the result |
1401 | Wait until either at least one request is in the result phase or no |
1380 | phase, wait till the result filehandle becomes ready for reading |
1402 | requests are outstanding anymore. |
1381 | (simply does a "select" on the filehandle. This is useful if you |
1403 | |
1382 | want to synchronously wait for some requests to finish). |
1404 | This is useful if you want to synchronously wait for some requests |
|
|
1405 | to become ready, without actually handling them. |
1383 | |
1406 | |
1384 | See "nreqs" for an example. |
1407 | See "nreqs" for an example. |
1385 | |
1408 | |
1386 | IO::AIO::poll |
1409 | IO::AIO::poll |
1387 | Waits until some requests have been handled. |
1410 | Waits until some requests have been handled. |