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.108 by root, Fri Jun 1 13:25:50 2007 UTC vs.
Revision 1.113 by root, Thu Sep 20 14:06:21 2007 UTC

195 195
196 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat 196 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat
197 aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink 197 aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink
198 aio_readlink aio_fsync aio_fdatasync aio_readahead aio_rename aio_link 198 aio_readlink aio_fsync aio_fdatasync aio_readahead aio_rename aio_link
199 aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir 199 aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir
200 aio_chown aio_chmod aio_utime); 200 aio_chown aio_chmod aio_utime aio_truncate);
201 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block)); 201 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block));
202 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush 202 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush
203 min_parallel max_parallel max_idle 203 min_parallel max_parallel max_idle
204 nreqs nready npending nthreads 204 nreqs nready npending nthreads
205 max_poll_time max_poll_reqs); 205 max_poll_time max_poll_reqs);
324 324
325=item aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) 325=item aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
326 326
327=item aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) 327=item aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
328 328
329Reads or writes C<length> bytes from the specified C<fh> and C<offset> 329Reads or writes C<$length> bytes from the specified C<$fh> and C<$offset>
330into the scalar given by C<data> and offset C<dataoffset> and calls the 330into the scalar given by C<$data> and offset C<$dataoffset> and calls the
331callback without the actual number of bytes read (or -1 on error, just 331callback without the actual number of bytes read (or -1 on error, just
332like the syscall).
333
332like the syscall). If C<offset> is undefined, then the current file offset 334If C<$offset> is undefined, then the current file descriptor offset will
333will be used (and updated), otherwise the file offset will not be changed 335be used (and updated), otherwise the file descriptor offset will not be
334by these calls. 336changed by these calls.
337
338If C<$length> is undefined in C<aio_write>, use the remaining length of C<$data>.
339
340If C<$dataoffset> is less than zero, it will be counted from the end of
341C<$data>.
335 342
336The C<$data> scalar I<MUST NOT> be modified in any way while the request 343The C<$data> scalar I<MUST NOT> be modified in any way while the request
337is outstanding. Modifying it can result in segfaults or World War III (if 344is outstanding. Modifying it can result in segfaults or World War III (if
338the necessary/optional hardware is installed). 345the necessary/optional hardware is installed).
339 346
435 442
436 # same as "chown root path" in the shell: 443 # same as "chown root path" in the shell:
437 aio_chown "path", 0, -1; 444 aio_chown "path", 0, -1;
438 # same as above: 445 # same as above:
439 aio_chown "path", 0, undef; 446 aio_chown "path", 0, undef;
447
448
449=item aio_truncate $fh_or_path, $offset, $callback->($status)
450
451Works like truncate(2) or ftruncate(2).
440 452
441 453
442=item aio_chmod $fh_or_path, $mode, $callback->($status) 454=item aio_chmod $fh_or_path, $mode, $callback->($status)
443 455
444Works like perl's C<chmod> function. 456Works like perl's C<chmod> function.
1195This is a very bad function to use in interactive programs because it 1207This is a very bad function to use in interactive programs because it
1196blocks, and a bad way to reduce concurrency because it is inexact: Better 1208blocks, and a bad way to reduce concurrency because it is inexact: Better
1197use an C<aio_group> together with a feed callback. 1209use an C<aio_group> together with a feed callback.
1198 1210
1199Sets the maximum number of outstanding requests to C<$nreqs>. If you 1211Sets the maximum number of outstanding requests to C<$nreqs>. If you
1200to queue up more than this number of requests, the next call to the 1212do queue up more than this number of requests, the next call to the
1201C<poll_cb> (and C<poll_some> and other functions calling C<poll_cb>) 1213C<poll_cb> (and C<poll_some> and other functions calling C<poll_cb>)
1202function will block until the limit is no longer exceeded. 1214function will block until the limit is no longer exceeded.
1203 1215
1204The default value is very large, so there is no practical limit on the 1216The default value is very large, so there is no practical limit on the
1205number of outstanding requests. 1217number of outstanding requests.
1284bytes of memory. In addition, stat requests need a stat buffer (possibly 1296bytes of memory. In addition, stat requests need a stat buffer (possibly
1285a few hundred bytes), readdir requires a result buffer and so on. Perl 1297a few hundred bytes), readdir requires a result buffer and so on. Perl
1286scalars and other data passed into aio requests will also be locked and 1298scalars and other data passed into aio requests will also be locked and
1287will consume memory till the request has entered the done state. 1299will consume memory till the request has entered the done state.
1288 1300
1289This is now awfully much, so queuing lots of requests is not usually a 1301This is not awfully much, so queuing lots of requests is not usually a
1290problem. 1302problem.
1291 1303
1292Per-thread usage: 1304Per-thread usage:
1293 1305
1294In the execution phase, some aio requests require more memory for 1306In the execution phase, some aio requests require more memory for

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines