ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/AIO.pm
(Generate patch)

Comparing Linux-AIO/AIO.pm (file contents):
Revision 1.32 by root, Sun Jul 10 15:00:38 2005 UTC vs.
Revision 1.36 by root, Wed Aug 17 16:57:53 2005 UTC

4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use Linux::AIO; 7 use Linux::AIO;
8 8
9 # This module has been mostly superseded by IO::AIO.
10
9=head1 DESCRIPTION 11=head1 DESCRIPTION
12
13I<This module has been mostly superseded by IO::AIO, which is API
14compatible.>
10 15
11This module implements asynchronous I/O using the means available to Linux 16This module implements asynchronous I/O using the means available to Linux
12- clone. It does not hook into the POSIX aio_* functions because Linux 17- clone. It does not hook into the POSIX aio_* functions because Linux
13does not yet support these in the kernel (even as of 2.6.12, only O_DIRECT 18does not yet support these in the kernel (even as of 2.6.12, only O_DIRECT
14files are supported) and even if, it would only allow aio_read and write, 19files are supported) and even if, it would only allow aio_read and write,
39All functions that expect a filehandle will also accept a file descriptor. 44All functions that expect a filehandle will also accept a file descriptor.
40 45
41The filenames you pass to these routines I<must> be absolute. The reason 46The filenames you pass to these routines I<must> be absolute. The reason
42is that at the time the request is being executed, the current working 47is that at the time the request is being executed, the current working
43directory could have changed. Alternatively, you can make sure that you 48directory could have changed. Alternatively, you can make sure that you
44never change the current workign directory. 49never change the current working directory.
45 50
46=over 4 51=over 4
47 52
48=cut 53=cut
49 54
50package Linux::AIO; 55package Linux::AIO;
51 56
52use base 'Exporter'; 57use base 'Exporter';
53 58
54BEGIN { 59BEGIN {
55 $VERSION = 1.71; 60 $VERSION = 1.8;
56 61
57 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink 62 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink
58 aio_fsync aio_fdatasync aio_readahead); 63 aio_fsync aio_fdatasync aio_readahead);
59 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); 64 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs);
60 65
128 133
129Asynchronously open or create a file and call the callback with the 134Asynchronously open or create a file and call the callback with the
130filedescriptor (NOT a perl filehandle, sorry for that, but watch out, this 135filedescriptor (NOT a perl filehandle, sorry for that, but watch out, this
131might change in the future). 136might change in the future).
132 137
138The pathname passed to C<aio_open> must be absolute. See API NOTES, above,
139for an explanation.
140
133The C<$mode> argument is a bitmask. See the C<Fcntl> module for a 141The C<$mode> argument is a bitmask. See the C<Fcntl> module for a
134list. They are the same as used in C<sysopen>. 142list. They are the same as used in C<sysopen>.
135 143
136Example: 144Example:
137 145
138 aio_open "/etc/passwd", O_RDONLY, 0, sub { 146 aio_open "/etc/passwd", O_RDONLY, 0, sub {
139 if ($_[0] >= 0) { 147 if ($_[0] >= 0) {
140 open my $fh, "<&$_[0]"; # create a copy for perl 148 open my $fh, "<&=$_[0]";
141 aio_close $_[0], sub { }; # close the aio handle
142 print "open successful, fh is $fh\n"; 149 print "open successful, fh is $fh\n";
143 ... 150 ...
144 } else { 151 } else {
145 die "open failed: $!\n"; 152 die "open failed: $!\n";
146 } 153 }
237 244
238 - aio_open gives a fd, but all other functions expect a perl filehandle. 245 - aio_open gives a fd, but all other functions expect a perl filehandle.
239 246
240=head1 SEE ALSO 247=head1 SEE ALSO
241 248
242L<Coro>. 249L<Coro>, L<IO::AIO>.
243 250
244=head1 AUTHOR 251=head1 AUTHOR
245 252
246 Marc Lehmann <schmorp@schmorp.de> 253 Marc Lehmann <schmorp@schmorp.de>
247 http://home.schmorp.de/ 254 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines