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.14 by root, Wed May 5 13:54:37 2004 UTC vs.
Revision 1.23 by root, Wed Jun 29 15:22:36 2005 UTC

16Instead, in this module a number of (non-posix) threads are started that 16Instead, in this module a number of (non-posix) threads are started that
17execute your read/writes and signal their completion. You don't need 17execute your read/writes and signal their completion. You don't need
18thread support in your libc or perl, and the threads created by this 18thread support in your libc or perl, and the threads created by this
19module will not be visible to the pthreads library. 19module will not be visible to the pthreads library.
20 20
21NOTICE: the threads created by this module will automatically be killed
22when the thread calling min_parallel exits. Make sure you only ever call
23min_parallel from the same thread that loaded this module.
24
25Although the module will work with threads, it is not reentrant, so use
26appropriate locking yourself.
27
21=over 4 28=over 4
22 29
23=cut 30=cut
24 31
25package Linux::AIO; 32package Linux::AIO;
26 33
27use base 'Exporter'; 34use base 'Exporter';
28 35
29BEGIN { 36BEGIN {
30 $VERSION = '1.0'; 37 $VERSION = 1.41;
31 38
32 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat); 39 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink);
33 @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);
34 41
35 require XSLoader; 42 require XSLoader;
36 XSLoader::load Linux::AIO, $VERSION; 43 XSLoader::load Linux::AIO, $VERSION;
37} 44}
38 45
39=item Linux::AIO::min_parallel $nthreads 46=item Linux::AIO::min_parallel $nthreads
40 47
41Set the minimum number of AIO threads to C<$nthreads>. You I<have> to call 48Set the minimum number of AIO threads to C<$nthreads>. The default is
42this function with a positive number at least once, otherwise no threads 49C<1>, which means a single asynchronous operation can be done at one time
43will be started and you aio-operations will seem to hang. 50(the number of outstanding operations, however, is unlimited).
44 51
45It is recommended to keep the number of threads low, as many linux 52It is recommended to keep the number of threads low, as many linux
46kernel versions will scale negatively with the number of threads (higher 53kernel versions will scale negatively with the number of threads (higher
47parallelity => MUCH higher latency). 54parallelity => MUCH higher latency).
48 55
62You can use Event to multiplex, e.g.: 69You can use Event to multiplex, e.g.:
63 70
64 Event->io (fd => Linux::AIO::poll_fileno, 71 Event->io (fd => Linux::AIO::poll_fileno,
65 poll => 'r', async => 1, 72 poll => 'r', async => 1,
66 cb => \&Linux::AIO::poll_cb ); 73 cb => \&Linux::AIO::poll_cb );
67
68 74
69=item Linux::AIO::nreqs 75=item Linux::AIO::nreqs
70 76
71Returns the number of requests currently outstanding. 77Returns the number of requests currently outstanding.
72 78
98 104
99Currently, the stats are always 64-bit-stats, i.e. instead of returning an 105Currently, the stats are always 64-bit-stats, i.e. instead of returning an
100error when stat'ing a large file, the results will be silently truncated 106error when stat'ing a large file, the results will be silently truncated
101unless perl itself is compiled with large file support. 107unless perl itself is compiled with large file support.
102 108
109=item aio_unlink $pathname, $callback
110
111Asynchronously unlink a file.
112
103=cut 113=cut
114
115min_parallel 1;
104 116
105END { 117END {
106 max_parallel 0; 118 max_parallel 0;
107} 119}
108 120
121 133
122L<Coro>. 134L<Coro>.
123 135
124=head1 AUTHOR 136=head1 AUTHOR
125 137
126 Marc Lehmann <pcg@goof.com> 138 Marc Lehmann <schmorp@schmorp.de>
127 http://www.goof.com/pcg/marc/ 139 http://home.schmorp.de/
128 140
129=cut 141=cut
130 142

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines