… | |
… | |
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.34; |
176 | our $VERSION = 4.35; |
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 |
… | |
… | |
252 | aio_syncfs $fh, $callback->($status) |
252 | aio_syncfs $fh, $callback->($status) |
253 | aio_fsync $fh, $callback->($status) |
253 | aio_fsync $fh, $callback->($status) |
254 | aio_fdatasync $fh, $callback->($status) |
254 | aio_fdatasync $fh, $callback->($status) |
255 | aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) |
255 | aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) |
256 | aio_pathsync $pathname, $callback->($status) |
256 | aio_pathsync $pathname, $callback->($status) |
257 | aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
257 | aio_msync $scalar, $offset = 0, $length = undef, flags = MS_SYNC, $callback->($status) |
258 | aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
258 | aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
259 | aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) |
259 | aio_mlock $scalar, $offset = 0, $length = undef, $callback->($status) |
260 | aio_mlockall $flags, $callback->($status) |
260 | aio_mlockall $flags, $callback->($status) |
261 | aio_group $callback->(...) |
261 | aio_group $callback->(...) |
262 | aio_nop $callback->() |
262 | aio_nop $callback->() |
… | |
… | |
1350 | }; |
1350 | }; |
1351 | |
1351 | |
1352 | $grp |
1352 | $grp |
1353 | } |
1353 | } |
1354 | |
1354 | |
1355 | =item aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
1355 | =item aio_msync $scalar, $offset = 0, $length = undef, flags = MS_SYNC, $callback->($status) |
1356 | |
1356 | |
1357 | This is a rather advanced IO::AIO call, which only works on mmap(2)ed |
1357 | This is a rather advanced IO::AIO call, which only works on mmap(2)ed |
1358 | scalars (see the C<IO::AIO::mmap> function, although it also works on data |
1358 | scalars (see the C<IO::AIO::mmap> function, although it also works on data |
1359 | scalars managed by the L<Sys::Mmap> or L<Mmap> modules, note that the |
1359 | scalars managed by the L<Sys::Mmap> or L<Mmap> modules, note that the |
1360 | scalar must only be modified in-place while an aio operation is pending on |
1360 | scalar must only be modified in-place while an aio operation is pending on |
… | |
… | |
1362 | |
1362 | |
1363 | It calls the C<msync> function of your OS, if available, with the memory |
1363 | It calls the C<msync> function of your OS, if available, with the memory |
1364 | area starting at C<$offset> in the string and ending C<$length> bytes |
1364 | area starting at C<$offset> in the string and ending C<$length> bytes |
1365 | later. If C<$length> is negative, counts from the end, and if C<$length> |
1365 | later. If C<$length> is negative, counts from the end, and if C<$length> |
1366 | is C<undef>, then it goes till the end of the string. The flags can be |
1366 | is C<undef>, then it goes till the end of the string. The flags can be |
1367 | a combination of C<IO::AIO::MS_ASYNC>, C<IO::AIO::MS_INVALIDATE> and |
1367 | either C<IO::AIO::MS_ASYNC> or C<IO::AIO::MS_SYNC>, plus an optional |
1368 | C<IO::AIO::MS_SYNC>. |
1368 | C<IO::AIO::MS_INVALIDATE>. |
1369 | |
1369 | |
1370 | =item aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
1370 | =item aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) |
1371 | |
1371 | |
1372 | This is a rather advanced IO::AIO call, which works best on mmap(2)ed |
1372 | This is a rather advanced IO::AIO call, which works best on mmap(2)ed |
1373 | scalars. |
1373 | scalars. |
… | |
… | |
2088 | |
2088 | |
2089 | Memory-maps a file (or anonymous memory range) and attaches it to the |
2089 | Memory-maps a file (or anonymous memory range) and attaches it to the |
2090 | given C<$scalar>, which will act like a string scalar. Returns true on |
2090 | given C<$scalar>, which will act like a string scalar. Returns true on |
2091 | success, and false otherwise. |
2091 | success, and false otherwise. |
2092 | |
2092 | |
|
|
2093 | The scalar must exist, but its contents do not matter - this means you |
|
|
2094 | cannot use a nonexistant array or hash element. When in doubt, C<undef> |
|
|
2095 | the scalar first. |
|
|
2096 | |
2093 | The only operations allowed on the scalar are C<substr>/C<vec> that don't |
2097 | The only operations allowed on the mmapped scalar are C<substr>/C<vec>, |
2094 | change the string length, and most read-only operations such as copying it |
2098 | which don't change the string length, and most read-only operations such |
2095 | or searching it with regexes and so on. |
2099 | as copying it or searching it with regexes and so on. |
2096 | |
2100 | |
2097 | Anything else is unsafe and will, at best, result in memory leaks. |
2101 | Anything else is unsafe and will, at best, result in memory leaks. |
2098 | |
2102 | |
2099 | The memory map associated with the C<$scalar> is automatically removed |
2103 | The memory map associated with the C<$scalar> is automatically removed |
2100 | when the C<$scalar> is destroyed, or when the C<IO::AIO::mmap> or |
2104 | when the C<$scalar> is undef'd or destroyed, or when the C<IO::AIO::mmap> |
2101 | C<IO::AIO::munmap> functions are called. |
2105 | or C<IO::AIO::munmap> functions are called on it. |
2102 | |
2106 | |
2103 | This calls the C<mmap>(2) function internally. See your system's manual |
2107 | This calls the C<mmap>(2) function internally. See your system's manual |
2104 | page for details on the C<$length>, C<$prot> and C<$flags> parameters. |
2108 | page for details on the C<$length>, C<$prot> and C<$flags> parameters. |
2105 | |
2109 | |
2106 | The C<$length> must be larger than zero and smaller than the actual |
2110 | The C<$length> must be larger than zero and smaller than the actual |