ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/README
Revision: 1.1
Committed: Tue Mar 8 20:19:00 2005 UTC (19 years, 2 months ago) by root
Branch: MAIN
CVS Tags: rel-1_6
Log Message:
*** empty log message ***

File Contents

# Content
1 NAME
2 Linux::AIO - linux-specific aio implemented using clone
3
4 SYNOPSIS
5 use Linux::AIO;
6
7 DESCRIPTION
8 This module implements asynchronous i/o using the means available to
9 linux - clone. It does not hook into the POSIX aio_* functions because
10 linux does not yet support these in the kernel (and even if, it would
11 only allow aio_read and write, not open and stat).
12
13 Instead, in this module a number of (non-posix) threads are started that
14 execute your read/writes and signal their completion. You don't need
15 thread support in your libc or perl, and the threads created by this
16 module will not be visible to the pthreads library.
17
18 NOTICE: the threads created by this module will automatically be killed
19 when the thread calling min_parallel exits. Make sure you only ever call
20 min_parallel from the same thread that loaded this module.
21
22 Although the module will work with threads, it is not reentrant, so use
23 appropriate locking yourself.
24
25 Linux::AIO::min_parallel $nthreads
26 Set the minimum number of AIO threads to $nthreads. The default is
27 1, which means a single asynchronous operation can be done at one
28 time (the number of outstanding operations, however, is unlimited).
29
30 It is recommended to keep the number of threads low, as many linux
31 kernel versions will scale negatively with the number of threads
32 (higher parallelity => MUCH higher latency).
33
34 $fileno = Linux::AIO::poll_fileno
35 Return the *request result pipe filehandle*. This filehandle must be
36 polled for reading by some mechanism outside this module (e.g. Event
37 or select, see below). If the pipe becomes readable you have to call
38 "poll_cb" to check the results.
39
40 Linux::AIO::poll_cb
41 Process all outstanding events on the result pipe. You have to call
42 this regularly. Returns the number of events processed. Returns
43 immediately when no events are outstanding.
44
45 You can use Event to multiplex, e.g.:
46
47 Event->io (fd => Linux::AIO::poll_fileno,
48 poll => 'r', async => 1,
49 cb => \&Linux::AIO::poll_cb );
50
51 Linux::AIO::nreqs
52 Returns the number of requests currently outstanding.
53
54 aio_open $pathname, $flags, $mode, $callback
55 Asynchronously open or create a file and call the callback with the
56 filedescriptor (NOT a perl filehandle, sorry for that, but watch
57 out, this might change in the future).
58
59 aio_close $fh, $callback
60 Asynchronously close a file and call the callback with the result
61 code.
62
63 aio_read $fh,$offset,$length, $data,$dataoffset,$callback
64 aio_write $fh,$offset,$length, $data,$dataoffset,$callback
65 Reads or writes "length" bytes from the specified "fh" and "offset"
66 into the scalar given by "data" and offset "dataoffset" and calls
67 the callback without the actual number of bytes read (or "undef" on
68 error).
69
70 aio_stat $fh_or_path, $callback
71 aio_lstat $fh, $callback
72 Works like perl's "stat" or "lstat" in void context. The callback
73 will be called after the stat and the results will be available
74 using "stat _" or "-s _" etc...
75
76 Currently, the stats are always 64-bit-stats, i.e. instead of
77 returning an error when stat'ing a large file, the results will be
78 silently truncated unless perl itself is compiled with large file
79 support.
80
81 aio_unlink $pathname, $callback
82 Asynchronously unlink a file.
83
84 BUGS
85 This module has been extensively tested in a large and very busy
86 webserver for many years now.
87
88 - aio_open gives a fd, but all other functions expect a perl filehandle.
89
90 SEE ALSO
91 Coro.
92
93 AUTHOR
94 Marc Lehmann <schmorp@schmorp.de>
95 http://home.schmorp.de/
96