--- IO-AIO/AIO.pm 2010/01/10 20:37:33 1.175 +++ IO-AIO/AIO.pm 2010/05/04 21:14:01 1.181 @@ -6,7 +6,7 @@ use IO::AIO; - aio_open "/etc/passwd", O_RDONLY, 0, sub { + aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub { my $fh = shift or die "/etc/passwd: $!"; ... @@ -78,7 +78,7 @@ my $aio_w = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb; # queue the request to open /etc/passwd - aio_open "/etc/passwd", O_RDONLY, 0, sub { + aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub { my $fh = shift or die "error while opening: $!"; @@ -170,7 +170,7 @@ use base 'Exporter'; BEGIN { - our $VERSION = '3.5'; + our $VERSION = '3.65'; our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx @@ -354,7 +354,7 @@ Example: - aio_open "/etc/passwd", O_RDONLY, 0, sub { + aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub { if ($_[0]) { print "open successful, fh is $_[0]\n"; ... @@ -426,7 +426,7 @@ This call tries to make use of a native C syscall to provide zero-copy operation. For this to work, C<$out_fh> should refer to a -socket, and C<$in_fh> should refer to mmap'able file. +socket, and C<$in_fh> should refer to an mmap'able file. If a native sendfile cannot be found or it fails with C, C, C, C, C or C, @@ -1086,9 +1086,10 @@ =item aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) This is a rather advanced IO::AIO call, which only works on mmap(2)ed -scalars (see the L or L modules for details on this, note -that the scalar must only be modified in-place while an aio operation is -pending on it). +scalars (see the C function, although it also works on data +scalars managed by the L or L modules, note that the +scalar must only be modified in-place while an aio operation is pending on +it). It calls the C function of your OS, if available, with the memory area starting at C<$offset> in the string and ending C<$length> bytes @@ -1547,6 +1548,60 @@ On systems that do not implement C, this function returns ENOSYS, otherwise the return value of C. +=item IO::AIO::mmap $scalar, $length, $prot, $flags, $fh[, $offset] + +Memory-maps a file (or anonymous memory range) and attaches it to the +given C<$scalar>, which will act like a string scalar. + +The only operations allowed on the scalar are C/C that don't +change the string length, and most read-only operations such as copying it +or searching it with regexes and so on. + +Anything else is unsafe and will, at best, result in memory leaks. + +The memory map associated with the C<$scalar> is automatically removed +when the C<$scalar> is destroyed, or when the C or +C functions are called. + +This calls the C(2) function internally. See your system's manual +page for details on the C<$length>, C<$prot> and C<$flags> parameters. + +The C<$length> must be larger than zero and smaller than the actual +filesize. + +C<$prot> is a combination of C, C, +C and/or C, + +C<$flags> can be a combination of C or +C, or a number of system-specific flags (when +not available, the are defined as 0): C +(which is set to C if your system only provides this +constant), C, C, +C, C or +C + +If C<$fh> is C, then a file descriptor of C<-1> is passed. + +C<$offset> is the offset from the start of the file - it generally must be +a multiple of C and defaults to C<0>. + +Example: + + use Digest::MD5; + use IO::AIO; + + open my $fh, ". + =item IO::AIO::mlockall $flags Calls the C function with the given C<$flags> (a combination of