ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/AIO.pm
Revision: 1.3
Committed: Tue Aug 14 23:25:39 2001 UTC (22 years, 9 months ago) by root
Branch: MAIN
Changes since 1.2: +16 -5 lines
Log Message:
*** empty log message ***

File Contents

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