… | |
… | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use Linux::AIO; |
7 | use Linux::AIO; |
8 | |
8 | |
9 | =head1 DESCRIPTION |
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. |
10 | |
16 | |
11 | =over 4 |
17 | =over 4 |
12 | |
18 | |
13 | =cut |
19 | =cut |
14 | |
20 | |
… | |
… | |
26 | XSLoader::load Linux::AIO, $VERSION; |
32 | XSLoader::load Linux::AIO, $VERSION; |
27 | } |
33 | } |
28 | |
34 | |
29 | =item Linux::AIO::min_parallel($nthreads) |
35 | =item Linux::AIO::min_parallel($nthreads) |
30 | |
36 | |
31 | Set the minimum number of AIO threads to $nthreads. |
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. |
32 | |
40 | |
33 | =cut |
41 | =cut |
34 | |
42 | |
35 | =item aio_read($fh,$offset,$length, $data,$dataoffset,$callback) |
43 | =item aio_read($fh,$offset,$length, $data,$dataoffset,$callback) |
36 | aio_write($fh,$offset,$length, $data,$dataoffset,$callback) |
44 | aio_write($fh,$offset,$length, $data,$dataoffset,$callback) |
… | |
… | |
47 | =item Linux::AIO::poll_cb |
55 | =item Linux::AIO::poll_cb |
48 | |
56 | |
49 | Process all outstanding events on the result pipe. You have to call this |
57 | Process all outstanding events on the result pipe. You have to call this |
50 | regularly. Returns the number of events processed. |
58 | regularly. Returns the number of events processed. |
51 | |
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 | |
52 | =item Linux::AIO::nreqs |
67 | =item Linux::AIO::nreqs |
53 | |
68 | |
54 | Returns the number of requests currently outstanding. |
69 | Returns the number of requests currently outstanding. |
55 | |
70 | |
56 | =cut |
71 | =cut |
… | |
… | |
65 | |
80 | |
66 | =head1 BUGS |
81 | =head1 BUGS |
67 | |
82 | |
68 | This module has not yet been extensively tested. Watch out! |
83 | This module has not yet been extensively tested. Watch out! |
69 | |
84 | |
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 |
85 | =head1 SEE ALSO |
75 | |
86 | |
76 | L<Coro>. |
87 | L<Coro>. |
77 | |
88 | |
78 | =head1 AUTHOR |
89 | =head1 AUTHOR |