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

Comparing IO-AIO/README (file contents):
Revision 1.39 by root, Wed Aug 5 11:53:16 2009 UTC vs.
Revision 1.42 by root, Thu Jan 7 20:25:57 2010 UTC

315 315
316 This call tries to make use of a native "sendfile" syscall to 316 This call tries to make use of a native "sendfile" syscall to
317 provide zero-copy operation. For this to work, $out_fh should refer 317 provide zero-copy operation. For this to work, $out_fh should refer
318 to a socket, and $in_fh should refer to mmap'able file. 318 to a socket, and $in_fh should refer to mmap'able file.
319 319
320 If the native sendfile call fails or is not implemented, it will be 320 If a native sendfile cannot be found or it fails with "ENOSYS",
321 "ENOTSUP", "EOPNOTSUPP", "EAFNOSUPPORT", "EPROTOTYPE" or "ENOTSOCK",
321 emulated, so you can call "aio_sendfile" on any type of filehandle 322 it will be emulated, so you can call "aio_sendfile" on any type of
322 regardless of the limitations of the operating system. 323 filehandle regardless of the limitations of the operating system.
323 324
324 Please note, however, that "aio_sendfile" can read more bytes from 325 Please note, however, that "aio_sendfile" can read more bytes from
325 $in_fh than are written, and there is no way to find out how many 326 $in_fh than are written, and there is no way to find out how many
326 bytes have been read from "aio_sendfile" alone, as "aio_sendfile" 327 bytes have been read from "aio_sendfile" alone, as "aio_sendfile"
327 only provides the number of bytes written to $out_fh. Only if the 328 only provides the number of bytes written to $out_fh. Only if the
362 aio_stat "/etc/passwd", sub { 363 aio_stat "/etc/passwd", sub {
363 $_[0] and die "stat failed: $!"; 364 $_[0] and die "stat failed: $!";
364 print "size is ", -s _, "\n"; 365 print "size is ", -s _, "\n";
365 }; 366 };
366 367
368 aio_statvfs $fh_or_path, $callback->($statvfs)
369 Works like the POSIX "statvfs" or "fstatvfs" syscalls, depending on
370 whether a file handle or path was passed.
371
372 On success, the callback is passed a hash reference with the
373 following members: "bsize", "frsize", "blocks", "bfree", "bavail",
374 "files", "ffree", "favail", "fsid", "flag" and "namemax". On
375 failure, "undef" is passed.
376
377 The following POSIX IO::AIO::ST_* constants are defined: "ST_RDONLY"
378 and "ST_NOSUID".
379
380 The following non-POSIX IO::AIO::ST_* flag masks are defined to
381 their correct value when available, or to 0 on systems that do not
382 support them: "ST_NODEV", "ST_NOEXEC", "ST_SYNCHRONOUS",
383 "ST_MANDLOCK", "ST_WRITE", "ST_APPEND", "ST_IMMUTABLE",
384 "ST_NOATIME", "ST_NODIRATIME" and "ST_RELATIME".
385
386 Example: stat "/wd" and dump out the data if successful.
387
388 aio_statvfs "/wd", sub {
389 my $f = $_[0]
390 or die "statvfs: $!";
391
392 use Data::Dumper;
393 say Dumper $f;
394 };
395
396 # result:
397 {
398 bsize => 1024,
399 bfree => 4333064312,
400 blocks => 10253828096,
401 files => 2050765568,
402 flag => 4096,
403 favail => 2042092649,
404 bavail => 4333064312,
405 ffree => 2042092649,
406 namemax => 255,
407 frsize => 1024,
408 fsid => 1810
409 }
410
367 aio_utime $fh_or_path, $atime, $mtime, $callback->($status) 411 aio_utime $fh_or_path, $atime, $mtime, $callback->($status)
368 Works like perl's "utime" function (including the special case of 412 Works like perl's "utime" function (including the special case of
369 $atime and $mtime being undef). Fractional times are supported if 413 $atime and $mtime being undef). Fractional times are supported if
370 the underlying syscalls support them. 414 the underlying syscalls support them.
371 415
512 into memory. Status is the same as with aio_read. 556 into memory. Status is the same as with aio_read.
513 557
514 aio_copy $srcpath, $dstpath, $callback->($status) 558 aio_copy $srcpath, $dstpath, $callback->($status)
515 Try to copy the *file* (directories not supported as either source 559 Try to copy the *file* (directories not supported as either source
516 or destination) from $srcpath to $dstpath and call the callback with 560 or destination) from $srcpath to $dstpath and call the callback with
517 the 0 (error) or -1 ok. 561 a status of 0 (ok) or -1 (error, see $!).
518 562
519 This is a composite request that creates the destination file with 563 This is a composite request that creates the destination file with
520 mode 0200 and copies the contents of the source file into it using 564 mode 0200 and copies the contents of the source file into it using
521 "aio_sendfile", followed by restoring atime, mtime, access mode and 565 "aio_sendfile", followed by restoring atime, mtime, access mode and
522 uid/gid, in that order. 566 uid/gid, in that order.
526 uid/gid, where errors are being ignored. 570 uid/gid, where errors are being ignored.
527 571
528 aio_move $srcpath, $dstpath, $callback->($status) 572 aio_move $srcpath, $dstpath, $callback->($status)
529 Try to move the *file* (directories not supported as either source 573 Try to move the *file* (directories not supported as either source
530 or destination) from $srcpath to $dstpath and call the callback with 574 or destination) from $srcpath to $dstpath and call the callback with
531 the 0 (error) or -1 ok. 575 a status of 0 (ok) or -1 (error, see $!).
532 576
533 This is a composite request that tries to rename(2) the file first; 577 This is a composite request that tries to rename(2) the file first;
534 if rename fails with "EXDEV", it copies the file with "aio_copy" 578 if rename fails with "EXDEV", it copies the file with "aio_copy"
535 and, if that is successful, unlinks the $srcpath. 579 and, if that is successful, unlinks the $srcpath.
536 580
636 Future versions of this function might fall back to other methods 680 Future versions of this function might fall back to other methods
637 when "fsync" on the directory fails (such as calling "sync"). 681 when "fsync" on the directory fails (such as calling "sync").
638 682
639 Passes 0 when everything went ok, and -1 on error. 683 Passes 0 when everything went ok, and -1 on error.
640 684
685 aio_msync $scalar, $offset = 0, $length = undef, flags = 0,
686 $callback->($status)
687 This is a rather advanced IO::AIO call, which only works on
688 mmap(2)ed scalars (see the Sys::Mmap or Mmap modules for details on
689 this, note that the scalar must only be modified in-place while an
690 aio operation is pending on it).
691
692 It calls the "msync" function of your OS, if available, with the
693 memory area starting at $offset in the string and ending $length
694 bytes later. If $length is negative, counts from the end, and if
695 $length is "undef", then it goes till the end of the string. The
696 flags can be a combination of "IO::AIO::MS_ASYNC",
697 "IO::AIO::MS_INVALIDATE" and "IO::AIO::MS_SYNC".
698
699 aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0,
700 $callback->($status)
701 This is a rather advanced IO::AIO call, which works best on
702 mmap(2)ed scalars.
703
704 It touches (reads or writes) all memory pages in the specified range
705 inside the scalar. All caveats and parameters are the same as for
706 "aio_msync", above, except for flags, which must be either 0 (which
707 reads all pages and ensures they are instantiated) or
708 "IO::AIO::MT_MODIFY", which modifies the memory page s(by reading
709 and writing an octet from it, which dirties the page).
710
641 aio_group $callback->(...) 711 aio_group $callback->(...)
642 This is a very special aio request: Instead of doing something, it 712 This is a very special aio request: Instead of doing something, it
643 is a container for other aio requests, which is useful if you want 713 is a container for other aio requests, which is useful if you want
644 to bundle many requests into a single, composite, request with a 714 to bundle many requests into a single, composite, request with a
645 definite callback and the ability to cancel the whole request with 715 definite callback and the ability to cancel the whole request with
760 830
761 $grp->cancel_subs 831 $grp->cancel_subs
762 Cancel all subrequests and clears any feeder, but not the group 832 Cancel all subrequests and clears any feeder, but not the group
763 request itself. Useful when you queued a lot of events but got a 833 request itself. Useful when you queued a lot of events but got a
764 result early. 834 result early.
835
836 The group request will finish normally (you cannot add requests to
837 the group).
765 838
766 $grp->result (...) 839 $grp->result (...)
767 Set the result value(s) that will be passed to the group callback 840 Set the result value(s) that will be passed to the group callback
768 when all subrequests have finished and set the groups errno to the 841 when all subrequests have finished and set the groups errno to the
769 current value of errno (just like calling "errno" without an error 842 current value of errno (just like calling "errno" without an error

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines