ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.pm
(Generate patch)

Comparing IO-AIO/AIO.pm (file contents):
Revision 1.267 by root, Tue Aug 9 11:39:17 2016 UTC vs.
Revision 1.268 by root, Tue May 30 22:45:52 2017 UTC

171use common::sense; 171use common::sense;
172 172
173use base 'Exporter'; 173use base 'Exporter';
174 174
175BEGIN { 175BEGIN {
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
1357This is a rather advanced IO::AIO call, which only works on mmap(2)ed 1357This is a rather advanced IO::AIO call, which only works on mmap(2)ed
1358scalars (see the C<IO::AIO::mmap> function, although it also works on data 1358scalars (see the C<IO::AIO::mmap> function, although it also works on data
1359scalars managed by the L<Sys::Mmap> or L<Mmap> modules, note that the 1359scalars managed by the L<Sys::Mmap> or L<Mmap> modules, note that the
1360scalar must only be modified in-place while an aio operation is pending on 1360scalar must only be modified in-place while an aio operation is pending on
1362 1362
1363It calls the C<msync> function of your OS, if available, with the memory 1363It calls the C<msync> function of your OS, if available, with the memory
1364area starting at C<$offset> in the string and ending C<$length> bytes 1364area starting at C<$offset> in the string and ending C<$length> bytes
1365later. If C<$length> is negative, counts from the end, and if C<$length> 1365later. If C<$length> is negative, counts from the end, and if C<$length>
1366is C<undef>, then it goes till the end of the string. The flags can be 1366is C<undef>, then it goes till the end of the string. The flags can be
1367a combination of C<IO::AIO::MS_ASYNC>, C<IO::AIO::MS_INVALIDATE> and 1367either C<IO::AIO::MS_ASYNC> or C<IO::AIO::MS_SYNC>, plus an optional
1368C<IO::AIO::MS_SYNC>. 1368C<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
1372This is a rather advanced IO::AIO call, which works best on mmap(2)ed 1372This is a rather advanced IO::AIO call, which works best on mmap(2)ed
1373scalars. 1373scalars.
2088 2088
2089Memory-maps a file (or anonymous memory range) and attaches it to the 2089Memory-maps a file (or anonymous memory range) and attaches it to the
2090given C<$scalar>, which will act like a string scalar. Returns true on 2090given C<$scalar>, which will act like a string scalar. Returns true on
2091success, and false otherwise. 2091success, and false otherwise.
2092 2092
2093The scalar must exist, but its contents do not matter - this means you
2094cannot use a nonexistant array or hash element. When in doubt, C<undef>
2095the scalar first.
2096
2093The only operations allowed on the scalar are C<substr>/C<vec> that don't 2097The only operations allowed on the mmapped scalar are C<substr>/C<vec>,
2094change the string length, and most read-only operations such as copying it 2098which don't change the string length, and most read-only operations such
2095or searching it with regexes and so on. 2099as copying it or searching it with regexes and so on.
2096 2100
2097Anything else is unsafe and will, at best, result in memory leaks. 2101Anything else is unsafe and will, at best, result in memory leaks.
2098 2102
2099The memory map associated with the C<$scalar> is automatically removed 2103The memory map associated with the C<$scalar> is automatically removed
2100when the C<$scalar> is destroyed, or when the C<IO::AIO::mmap> or 2104when the C<$scalar> is undef'd or destroyed, or when the C<IO::AIO::mmap>
2101C<IO::AIO::munmap> functions are called. 2105or C<IO::AIO::munmap> functions are called on it.
2102 2106
2103This calls the C<mmap>(2) function internally. See your system's manual 2107This calls the C<mmap>(2) function internally. See your system's manual
2104page for details on the C<$length>, C<$prot> and C<$flags> parameters. 2108page for details on the C<$length>, C<$prot> and C<$flags> parameters.
2105 2109
2106The C<$length> must be larger than zero and smaller than the actual 2110The C<$length> must be larger than zero and smaller than the actual

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines