… | |
… | |
16 | Instead, in this module a number of (non-posix) threads are started that |
16 | Instead, in this module a number of (non-posix) threads are started that |
17 | execute your read/writes and signal their completion. You don't need |
17 | execute your read/writes and signal their completion. You don't need |
18 | thread support in your libc or perl, and the threads created by this |
18 | thread support in your libc or perl, and the threads created by this |
19 | module will not be visible to the pthreads library. |
19 | module will not be visible to the pthreads library. |
20 | |
20 | |
|
|
21 | Although the module will work with threads, it is not reentrant, so use |
|
|
22 | appropriate locking yourself. |
|
|
23 | |
21 | =over 4 |
24 | =over 4 |
22 | |
25 | |
23 | =cut |
26 | =cut |
24 | |
27 | |
25 | package Linux::AIO; |
28 | package Linux::AIO; |
26 | |
29 | |
27 | use base 'Exporter'; |
30 | use base 'Exporter'; |
28 | |
31 | |
29 | BEGIN { |
32 | BEGIN { |
30 | $VERSION = 1.01; |
33 | $VERSION = 1.1; |
31 | |
34 | |
32 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat); |
35 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat); |
33 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
36 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
34 | |
37 | |
35 | require XSLoader; |
38 | require XSLoader; |
36 | XSLoader::load Linux::AIO, $VERSION; |
39 | XSLoader::load Linux::AIO, $VERSION; |
37 | } |
40 | } |
38 | |
41 | |
39 | =item Linux::AIO::min_parallel $nthreads |
42 | =item Linux::AIO::min_parallel $nthreads |
40 | |
43 | |
41 | Set the minimum number of AIO threads to C<$nthreads>. You I<have> to call |
44 | Set the minimum number of AIO threads to C<$nthreads>. The default is |
42 | this function with a positive number at least once, otherwise no threads |
45 | C<1>, which means a single asynchronous operation can be done at one time |
43 | will be started and you aio-operations will seem to hang. |
46 | (the number of outstanding operations, however, is unlimited). |
44 | |
47 | |
45 | It is recommended to keep the number of threads low, as many linux |
48 | It is recommended to keep the number of threads low, as many linux |
46 | kernel versions will scale negatively with the number of threads (higher |
49 | kernel versions will scale negatively with the number of threads (higher |
47 | parallelity => MUCH higher latency). |
50 | parallelity => MUCH higher latency). |
48 | |
51 | |
… | |
… | |
100 | error when stat'ing a large file, the results will be silently truncated |
103 | error when stat'ing a large file, the results will be silently truncated |
101 | unless perl itself is compiled with large file support. |
104 | unless perl itself is compiled with large file support. |
102 | |
105 | |
103 | =cut |
106 | =cut |
104 | |
107 | |
|
|
108 | min_parallel 1; |
|
|
109 | |
105 | END { |
110 | END { |
106 | max_parallel 0; |
111 | max_parallel 0; |
107 | } |
112 | } |
108 | |
113 | |
109 | 1; |
114 | 1; |