| 1 |
root |
1.1 |
=head1 NAME |
| 2 |
|
|
|
| 3 |
|
|
Linux::AIO - linux-specific aio implemented using clone |
| 4 |
|
|
|
| 5 |
|
|
=head1 SYNOPSIS |
| 6 |
|
|
|
| 7 |
|
|
use Linux::AIO; |
| 8 |
|
|
|
| 9 |
|
|
=head1 DESCRIPTION |
| 10 |
|
|
|
| 11 |
|
|
=over 4 |
| 12 |
|
|
|
| 13 |
|
|
=cut |
| 14 |
|
|
|
| 15 |
|
|
package Linux::AIO; |
| 16 |
|
|
|
| 17 |
root |
1.2 |
use base 'Exporter'; |
| 18 |
|
|
|
| 19 |
root |
1.1 |
BEGIN { |
| 20 |
|
|
$VERSION = 0.001; |
| 21 |
|
|
|
| 22 |
root |
1.2 |
@EXPORT = qw(aio_read aio_write); |
| 23 |
|
|
@EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
| 24 |
|
|
|
| 25 |
root |
1.1 |
require XSLoader; |
| 26 |
|
|
XSLoader::load Linux::AIO, $VERSION; |
| 27 |
|
|
} |
| 28 |
|
|
|
| 29 |
|
|
=item Linux::AIO::min_parallel($nthreads) |
| 30 |
|
|
|
| 31 |
|
|
Set the minimum number of AIO threads to $nthreads. |
| 32 |
|
|
|
| 33 |
|
|
=cut |
| 34 |
|
|
|
| 35 |
root |
1.2 |
=item aio_read($fh,$offset,$length, $data,$dataoffset,$callback) |
| 36 |
|
|
aio_write($fh,$offset,$length, $data,$dataoffset,$callback) |
| 37 |
root |
1.1 |
|
| 38 |
|
|
Reads or writes C<length> bytes from the specified C<fh> and C<offset> |
| 39 |
|
|
into the scalar given by C<data> and offset C<dataoffset> and calls the |
| 40 |
|
|
callback without the actual number of bytes read (or undef on error). |
| 41 |
|
|
|
| 42 |
root |
1.2 |
=item $fileno = Linux::AIO::poll_fileno |
| 43 |
|
|
|
| 44 |
|
|
Return the request result pipe filehandle. This filehandle must be polled |
| 45 |
|
|
for reading. If the pipe becomes readable you have to call C<poll_cb>. |
| 46 |
|
|
|
| 47 |
|
|
=item Linux::AIO::poll_cb |
| 48 |
|
|
|
| 49 |
|
|
Process all outstanding events on the result pipe. You have to call this |
| 50 |
|
|
regularly. Returns the number of events processed. |
| 51 |
|
|
|
| 52 |
|
|
=item Linux::AIO::nreqs |
| 53 |
|
|
|
| 54 |
|
|
Returns the number of requests currently outstanding. |
| 55 |
|
|
|
| 56 |
root |
1.1 |
=cut |
| 57 |
root |
1.2 |
|
| 58 |
|
|
END { |
| 59 |
|
|
max_parallel 0; |
| 60 |
|
|
} |
| 61 |
root |
1.1 |
|
| 62 |
|
|
1; |
| 63 |
|
|
|
| 64 |
|
|
=back |
| 65 |
|
|
|
| 66 |
|
|
=head1 BUGS |
| 67 |
|
|
|
| 68 |
|
|
This module has not yet been extensively tested. Watch out! |
| 69 |
|
|
|
| 70 |
|
|
This module does not use the aio_* posix functions because a) linux does |
| 71 |
|
|
not have aio, b) the existing aio_* functions use pthreads, which are too |
| 72 |
|
|
buggy for my usage. |
| 73 |
|
|
|
| 74 |
|
|
=head1 SEE ALSO |
| 75 |
|
|
|
| 76 |
|
|
L<Coro>. |
| 77 |
|
|
|
| 78 |
|
|
=head1 AUTHOR |
| 79 |
|
|
|
| 80 |
|
|
Marc Lehmann <pcg@goof.com> |
| 81 |
|
|
http://www.goof.com/pcg/marc/ |
| 82 |
|
|
|
| 83 |
|
|
=cut |
| 84 |
|
|
|