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.1 by root, Tue Aug 14 03:18:53 2001 UTC vs.
Revision 1.7 by root, Mon Oct 8 12:58:41 2001 UTC

6 6
7 use Linux::AIO; 7 use Linux::AIO;
8 8
9=head1 DESCRIPTION 9=head1 DESCRIPTION
10 10
11This module implements asynchroneous i/o using the means available to
12linux - clone. It does not hook into the POSIX aio_* functions because
13linux does not yet support these in the kernel. Instead, a number of
14threads are started that execute your read/writes and signal their
15completion.
16
11=over 4 17=over 4
12 18
13=cut 19=cut
14 20
15package Linux::AIO; 21package Linux::AIO;
16 22
23use base 'Exporter';
24
17BEGIN { 25BEGIN {
18 $VERSION = 0.001; 26 $VERSION = 0.01;
27
28 @EXPORT = qw(aio_read aio_write aio_open aio_close);
29 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs);
19 30
20 require XSLoader; 31 require XSLoader;
21 XSLoader::load Linux::AIO, $VERSION; 32 XSLoader::load Linux::AIO, $VERSION;
22} 33}
23 34
24use base 'Exporter';
25
26=item Linux::AIO::min_parallel($nthreads) 35=item Linux::AIO::min_parallel($nthreads)
27 36
28Set the minimum number of AIO threads to $nthreads. 37Set the minimum number of AIO threads to $nthreads. You I<have> to call
38this function with a positive number at leats once, otherwise no threads
39will be started and you aio-operations will seem to hang.
29 40
30=cut 41=item $fileno = Linux::AIO::poll_fileno
31 42
43Return the request result pipe filehandle. This filehandle must be polled
44for reading. If the pipe becomes readable you have to call C<poll_cb>.
45
46=item Linux::AIO::poll_cb
47
48Process all outstanding events on the result pipe. You have to call this
49regularly. Returns the number of events processed.
50
51You can use Event to multiplex, e.g.:
52
53 Event->io(fd => Linux::AIO::poll_fileno,
54 poll => 'r', async => 1,
55 cb => \&Linux::AIO::poll_cb );
56
57
58=item Linux::AIO::nreqs
59
60Returns the number of requests currently outstanding.
61
32=item Linux::AIO::read($fh,$offset,$length, $data,$dataoffset,$callback) 62=item aio_read($fh,$offset,$length, $data,$dataoffset,$callback)
33Linux::AIO::write($fh,$offset,$length, $data,$dataoffset,$callback) 63aio_write($fh,$offset,$length, $data,$dataoffset,$callback)
34 64
35Reads or writes C<length> bytes from the specified C<fh> and C<offset> 65Reads or writes C<length> bytes from the specified C<fh> and C<offset>
36into the scalar given by C<data> and offset C<dataoffset> and calls the 66into the scalar given by C<data> and offset C<dataoffset> and calls the
37callback without the actual number of bytes read (or undef on error). 67callback without the actual number of bytes read (or undef on error).
38 68
69=item aio_open($pathname, $flags, $mode, $callback)
70
71Asynchronously open or create a file and call the callback with the
72filedescriptor.
73
74=item aio_close($fh, $callback)
75
76Asynchronously close a file and call the callback with the result code.
77
39=cut 78=cut
79
80END {
81 max_parallel 0;
82}
40 83
411; 841;
42 85
43=back 86=back
44 87
45=head1 BUGS 88=head1 BUGS
46 89
47This module has not yet been extensively tested. Watch out! 90This module has not yet been extensively tested. Watch out!
48 91
49This module does not use the aio_* posix functions because a) linux does 92 - aio_stat/lstat are seriously missing here.
50not have aio, b) the existing aio_* functions use pthreads, which are too
51buggy for my usage.
52 93
53=head1 SEE ALSO 94=head1 SEE ALSO
54 95
55L<Coro>. 96L<Coro>.
56 97

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines