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.23 by root, Wed Jun 29 15:22:36 2005 UTC vs.
Revision 1.24 by root, Wed Jun 29 15:28:14 2005 UTC

32package Linux::AIO; 32package Linux::AIO;
33 33
34use base 'Exporter'; 34use base 'Exporter';
35 35
36BEGIN { 36BEGIN {
37 $VERSION = 1.41; 37 $VERSION = 1.5;
38 38
39 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink); 39 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink);
40 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); 40 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs);
41 41
42 require XSLoader; 42 require XSLoader;
47 47
48Set the minimum number of AIO threads to C<$nthreads>. The default is 48Set the minimum number of AIO threads to C<$nthreads>. The default is
49C<1>, which means a single asynchronous operation can be done at one time 49C<1>, which means a single asynchronous operation can be done at one time
50(the number of outstanding operations, however, is unlimited). 50(the number of outstanding operations, however, is unlimited).
51 51
52It is recommended to keep the number of threads low, as many linux 52It is recommended to keep the number of threads low, as some linux
53kernel versions will scale negatively with the number of threads (higher 53kernel versions will scale negatively with the number of threads (higher
54parallelity => MUCH higher latency). 54parallelity => MUCH higher latency).
55
56=item Linux::AIO::max_parallel $nthreads
57
58Sets the maximum number of AIO threads to C<$nthreads>. If more than
59the specified number of threads are currently running, kill them. This
60function blocks until the limit is reached.
61
62This module automatically runs C<max_parallel 0> at program end, to ensure
63that all threads are killed and that there are no outstanding requests.
55 64
56=item $fileno = Linux::AIO::poll_fileno 65=item $fileno = Linux::AIO::poll_fileno
57 66
58Return the I<request result pipe filehandle>. This filehandle must be 67Return the I<request result pipe filehandle>. This filehandle must be
59polled for reading by some mechanism outside this module (e.g. Event 68polled for reading by some mechanism outside this module (e.g. Event
69You can use Event to multiplex, e.g.: 78You can use Event to multiplex, e.g.:
70 79
71 Event->io (fd => Linux::AIO::poll_fileno, 80 Event->io (fd => Linux::AIO::poll_fileno,
72 poll => 'r', async => 1, 81 poll => 'r', async => 1,
73 cb => \&Linux::AIO::poll_cb ); 82 cb => \&Linux::AIO::poll_cb );
83
84=item Linux::AIO::poll_wait
85
86Wait till the result filehandle becomes ready for reading (simply does a
87select on the filehandle. This is useful if you want to synchronously wait
88for some requests to finish).
74 89
75=item Linux::AIO::nreqs 90=item Linux::AIO::nreqs
76 91
77Returns the number of requests currently outstanding. 92Returns the number of requests currently outstanding.
78 93

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines