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.166 by root, Thu Nov 12 00:01:52 2009 UTC vs.
Revision 1.171 by root, Sat Jan 2 14:24:32 2010 UTC

191use common::sense; 191use common::sense;
192 192
193use base 'Exporter'; 193use base 'Exporter';
194 194
195BEGIN { 195BEGIN {
196 our $VERSION = '3.3'; 196 our $VERSION = '3.4';
197 197
198 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close 198 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close
199 aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx 199 aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx
200 aio_scandir aio_symlink aio_readlink aio_sync aio_fsync 200 aio_scandir aio_symlink aio_readlink aio_sync aio_fsync
201 aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead 201 aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead
202 aio_rename aio_link aio_move aio_copy aio_group 202 aio_rename aio_link aio_move aio_copy aio_group
203 aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown 203 aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown
204 aio_chmod aio_utime aio_truncate); 204 aio_chmod aio_utime aio_truncate
205 aio_msync aio_mtouch);
205 206
206 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); 207 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice));
207 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush 208 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush
208 min_parallel max_parallel max_idle 209 min_parallel max_parallel max_idle
209 nreqs nready npending nthreads 210 nreqs nready npending nthreads
380 381
381This call tries to make use of a native C<sendfile> syscall to provide 382This call tries to make use of a native C<sendfile> syscall to provide
382zero-copy operation. For this to work, C<$out_fh> should refer to a 383zero-copy operation. For this to work, C<$out_fh> should refer to a
383socket, and C<$in_fh> should refer to mmap'able file. 384socket, and C<$in_fh> should refer to mmap'able file.
384 385
385If the native sendfile call fails or is not implemented, it will be 386If a native sendfile cannot be found or it fails with C<ENOSYS>,
387C<ENOTSUP>, C<EOPNOTSUPP>, C<EAFNOSUPPORT>, C<EPROTOTYPE> or C<ENOTSOCK>,
386emulated, so you can call C<aio_sendfile> on any type of filehandle 388it will be emulated, so you can call C<aio_sendfile> on any type of
387regardless of the limitations of the operating system. 389filehandle regardless of the limitations of the operating system.
388 390
389Please note, however, that C<aio_sendfile> can read more bytes from 391Please note, however, that C<aio_sendfile> can read more bytes from
390C<$in_fh> than are written, and there is no way to find out how many 392C<$in_fh> than are written, and there is no way to find out how many
391bytes have been read from C<aio_sendfile> alone, as C<aio_sendfile> only 393bytes have been read from C<aio_sendfile> alone, as C<aio_sendfile> only
392provides the number of bytes written to C<$out_fh>. Only if the result 394provides the number of bytes written to C<$out_fh>. Only if the result
989 }; 991 };
990 992
991 $grp 993 $grp
992} 994}
993 995
996=item aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status)
997
998This is a rather advanced IO::AIO call, which only works on mmap(2)ed
999scalars (see the L<Sys::Mmap> or L<Mmap> modules for details on this, note
1000that the scalar must only be modified in-place while an aio operation is
1001pending on it).
1002
1003It calls the C<msync> function of your OS, if available, with the memory
1004area starting at C<$offset> in the string and ending C<$length> bytes
1005later. If C<$length> is negative, counts from the end, and if C<$length>
1006is C<undef>, then it goes till the end of the string. The flags can be
1007a combination of C<IO::AIO::MS_ASYNC>, C<IO::AIO::MS_INVALIDATE> and
1008C<IO::AIO::MS_SYNC>.
1009
1010=item aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status)
1011
1012This is a rather advanced IO::AIO call, which works best on mmap(2)ed
1013scalars.
1014
1015It touches (reads or writes) all memory pages in the specified
1016range inside the scalar. All caveats and parameters are the same
1017as for C<aio_msync>, above, except for flags, which must be either
1018C<0> (which reads all pages and ensures they are instantiated) or
1019C<IO::AIO::MT_MODIFY>, which modifies the memory page s(by reading and
1020writing an octet from it, which dirties the page).
1021
994=item aio_group $callback->(...) 1022=item aio_group $callback->(...)
995 1023
996This is a very special aio request: Instead of doing something, it is a 1024This is a very special aio request: Instead of doing something, it is a
997container for other aio requests, which is useful if you want to bundle 1025container for other aio requests, which is useful if you want to bundle
998many requests into a single, composite, request with a definite callback 1026many requests into a single, composite, request with a definite callback
1132 1160
1133=item $grp->cancel_subs 1161=item $grp->cancel_subs
1134 1162
1135Cancel all subrequests and clears any feeder, but not the group request 1163Cancel all subrequests and clears any feeder, but not the group request
1136itself. Useful when you queued a lot of events but got a result early. 1164itself. Useful when you queued a lot of events but got a result early.
1165
1166The group request will finish normally (you cannot add requests to the
1167group).
1137 1168
1138=item $grp->result (...) 1169=item $grp->result (...)
1139 1170
1140Set the result value(s) that will be passed to the group callback when all 1171Set the result value(s) that will be passed to the group callback when all
1141subrequests have finished and set the groups errno to the current value 1172subrequests have finished and set the groups errno to the current value

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines