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.22 by root, Wed Jul 20 21:55:27 2005 UTC vs.
Revision 1.23 by root, Fri Jul 22 08:25:22 2005 UTC

56 56
57=cut 57=cut
58 58
59package IO::AIO; 59package IO::AIO;
60 60
61no warnings;
62
61use base 'Exporter'; 63use base 'Exporter';
62 64
63use Fcntl (); 65use Fcntl ();
64 66
65BEGIN { 67BEGIN {
66 $VERSION = 0.9; 68 $VERSION = '1.0';
67 69
68 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink 70 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink
69 aio_fsync aio_fdatasync aio_readahead); 71 aio_fsync aio_fdatasync aio_readahead);
70 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel max_outstanding nreqs); 72 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel max_outstanding nreqs);
71 73
83which must be a code reference. This code reference will get called with 85which must be a code reference. This code reference will get called with
84the syscall return code (e.g. most syscalls return C<-1> on error, unlike 86the syscall return code (e.g. most syscalls return C<-1> on error, unlike
85perl, which usually delivers "false") as it's sole argument when the given 87perl, which usually delivers "false") as it's sole argument when the given
86syscall has been executed asynchronously. 88syscall has been executed asynchronously.
87 89
88All functions that expect a filehandle will also accept a file descriptor. 90All functions expecting a filehandle keep a copy of the filehandle
91internally until the request has finished.
89 92
90The filenames you pass to these routines I<must> be absolute. The reason 93The filenames you pass to these routines I<must> be absolute. The reason
91for this is that at the time the request is being executed, the current 94for this is that at the time the request is being executed, the current
92working directory could have changed. Alternatively, you can make sure 95working directory could have changed. Alternatively, you can make sure
93that you never change the current working directory. 96that you never change the current working directory.
310 313
311# support function to convert a fd into a perl filehandle 314# support function to convert a fd into a perl filehandle
312sub _fd2fh { 315sub _fd2fh {
313 return undef if $_[0] < 0; 316 return undef if $_[0] < 0;
314 317
315 # try to be perl5.6-compatible 318 # try to generate nice filehandles
316 local *AIO_FH; 319 my $sym = "IO::AIO::fd#$_[0]";
320 local *$sym;
317 open AIO_FH, "+<&=$_[0]" 321 open *$sym, "+<&=$_[0]"
318 or return undef; 322 or return undef;
319 323
320 *AIO_FH 324 *$sym
321} 325}
322 326
323min_parallel 4; 327min_parallel 4;
324 328
325END { 329END {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines