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.24 by root, Sun Jul 31 18:45:48 2005 UTC vs.
Revision 1.26 by root, Sun Aug 7 03:34:07 2005 UTC

152 print "read $_[0] bytes: <$buffer>\n"; 152 print "read $_[0] bytes: <$buffer>\n";
153 }; 153 };
154 154
155=item aio_readahead $fh,$offset,$length, $callback 155=item aio_readahead $fh,$offset,$length, $callback
156 156
157Asynchronously reads the specified byte range into the page cache, using
158the C<readahead> syscall. If that syscall doesn't exist (likely if your OS
159isn't Linux) the status will be C<-1> and C<$!> is set to C<ENOSYS>.
160
161C<aio_readahead> populates the page cache with data from a file so that 157C<aio_readahead> populates the page cache with data from a file so that
162subsequent reads from that file will not block on disk I/O. The C<$offset> 158subsequent reads from that file will not block on disk I/O. The C<$offset>
163argument specifies the starting point from which data is to be read and 159argument specifies the starting point from which data is to be read and
164C<$length> specifies the number of bytes to be read. I/O is performed in 160C<$length> specifies the number of bytes to be read. I/O is performed in
165whole pages, so that offset is effectively rounded down to a page boundary 161whole pages, so that offset is effectively rounded down to a page boundary
166and bytes are read up to the next page boundary greater than or equal to 162and bytes are read up to the next page boundary greater than or equal to
167(off-set+length). C<aio_readahead> does not read beyond the end of the 163(off-set+length). C<aio_readahead> does not read beyond the end of the
168file. The current file offset of the file is left unchanged. 164file. The current file offset of the file is left unchanged.
169 165
166If that syscall doesn't exist (likely if your OS isn't Linux) it will be
167emulated by simply reading the data, which would have a similar effect.
168
170=item aio_stat $fh_or_path, $callback 169=item aio_stat $fh_or_path, $callback
171 170
172=item aio_lstat $fh, $callback 171=item aio_lstat $fh, $callback
173 172
174Works like perl's C<stat> or C<lstat> in void context. The callback will 173Works like perl's C<stat> or C<lstat> in void context. The callback will
200with the fsync result code. 199with the fsync result code.
201 200
202=item aio_fdatasync $fh, $callback 201=item aio_fdatasync $fh, $callback
203 202
204Asynchronously call fdatasync on the given filehandle and call the 203Asynchronously call fdatasync on the given filehandle and call the
205callback with the fdatasync result code. Might set C<$!> to C<ENOSYS> if 204callback with the fdatasync result code.
206C<fdatasync> is not available. 205
206If this call isn't available because your OS lacks it or it couldn't be
207detected, it will be emulated by calling C<fsync> instead.
207 208
208=back 209=back
209 210
210=head2 SUPPORT FUNCTIONS 211=head2 SUPPORT FUNCTIONS
211 212
316 return undef if $_[0] < 0; 317 return undef if $_[0] < 0;
317 318
318 # try to generate nice filehandles 319 # try to generate nice filehandles
319 my $sym = "IO::AIO::fd#$_[0]"; 320 my $sym = "IO::AIO::fd#$_[0]";
320 local *$sym; 321 local *$sym;
321 open *$sym, "+<&=$_[0]" 322
323 open *$sym, "+<&$_[0]" # usually under any unix
324 or open *$sym, "<&$_[0]" # cygwin needs this
325 or open *$sym, ">&$_[0]" # cygwin needs this
322 or return undef; 326 or return undef;
323 327
324 *$sym 328 *$sym
325} 329}
326 330

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines