… | |
… | |
12 | |
12 | |
13 | =cut |
13 | =cut |
14 | |
14 | |
15 | package Linux::AIO; |
15 | package Linux::AIO; |
16 | |
16 | |
|
|
17 | use base 'Exporter'; |
|
|
18 | |
17 | BEGIN { |
19 | BEGIN { |
18 | $VERSION = 0.001; |
20 | $VERSION = 0.001; |
|
|
21 | |
|
|
22 | @EXPORT = qw(aio_read aio_write); |
|
|
23 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
19 | |
24 | |
20 | require XSLoader; |
25 | require XSLoader; |
21 | XSLoader::load Linux::AIO, $VERSION; |
26 | XSLoader::load Linux::AIO, $VERSION; |
22 | } |
27 | } |
23 | |
|
|
24 | use base 'Exporter'; |
|
|
25 | |
28 | |
26 | =item Linux::AIO::min_parallel($nthreads) |
29 | =item Linux::AIO::min_parallel($nthreads) |
27 | |
30 | |
28 | Set the minimum number of AIO threads to $nthreads. |
31 | Set the minimum number of AIO threads to $nthreads. |
29 | |
32 | |
30 | =cut |
33 | =cut |
31 | |
34 | |
32 | =item Linux::AIO::read($fh,$offset,$length, $data,$dataoffset,$callback) |
35 | =item aio_read($fh,$offset,$length, $data,$dataoffset,$callback) |
33 | Linux::AIO::write($fh,$offset,$length, $data,$dataoffset,$callback) |
36 | aio_write($fh,$offset,$length, $data,$dataoffset,$callback) |
34 | |
37 | |
35 | Reads or writes C<length> bytes from the specified C<fh> and C<offset> |
38 | Reads or writes C<length> bytes from the specified C<fh> and C<offset> |
36 | into the scalar given by C<data> and offset C<dataoffset> and calls the |
39 | into the scalar given by C<data> and offset C<dataoffset> and calls the |
37 | callback without the actual number of bytes read (or undef on error). |
40 | callback without the actual number of bytes read (or undef on error). |
38 | |
41 | |
|
|
42 | =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 | |
39 | =cut |
56 | =cut |
|
|
57 | |
|
|
58 | END { |
|
|
59 | max_parallel 0; |
|
|
60 | } |
40 | |
61 | |
41 | 1; |
62 | 1; |
42 | |
63 | |
43 | =back |
64 | =back |
44 | |
65 | |