ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/README
(Generate patch)

Comparing IO-AIO/README (file contents):
Revision 1.5 by root, Sun Jul 10 23:45:16 2005 UTC vs.
Revision 1.6 by root, Mon Jul 11 03:29:39 2005 UTC

20 poll => 'r', 20 poll => 'r',
21 cb => \&IO::AIO::poll_cb); 21 cb => \&IO::AIO::poll_cb);
22 22
23 # Glib/Gtk2 23 # Glib/Gtk2
24 add_watch Glib::IO IO::AIO::poll_fileno, 24 add_watch Glib::IO IO::AIO::poll_fileno,
25 \&IO::AIO::poll_cb; 25 in => sub { IO::AIO::poll_cb, 1 };
26 26
27 # Tk 27 # Tk
28 Tk::Event::IO->fileevent (IO::AIO::poll_fileno, "", 28 Tk::Event::IO->fileevent (IO::AIO::poll_fileno, "",
29 readable => \&IO::AIO::poll_cb); 29 readable => \&IO::AIO::poll_cb);
30
31 # Danga::Socket
32 Danga::Socket->AddOtherFds (IO::AIO::poll_fileno =>
33 \&IO::AIO::poll_cb);
30 34
31DESCRIPTION 35DESCRIPTION
32 This module implements asynchronous I/O using whatever means your 36 This module implements asynchronous I/O using whatever means your
33 operating system supports. 37 operating system supports.
34 38
47 51
48FUNCTIONS 52FUNCTIONS
49 AIO FUNCTIONS 53 AIO FUNCTIONS
50 All the "aio_*" calls are more or less thin wrappers around the syscall 54 All the "aio_*" calls are more or less thin wrappers around the syscall
51 with the same name (sans "aio_"). The arguments are similar or 55 with the same name (sans "aio_"). The arguments are similar or
52 identical, and they all accept an additional $callback argument which 56 identical, and they all accept an additional (and optional) $callback
53 must be a code reference. This code reference will get called with the 57 argument which must be a code reference. This code reference will get
54 syscall return code (e.g. most syscalls return -1 on error, unlike perl, 58 called with the syscall return code (e.g. most syscalls return -1 on
55 which usually delivers "false") as it's sole argument when the given 59 error, unlike perl, which usually delivers "false") as it's sole
56 syscall has been executed asynchronously. 60 argument when the given syscall has been executed asynchronously.
57 61
58 All functions that expect a filehandle will also accept a file 62 All functions that expect a filehandle will also accept a file
59 descriptor. 63 descriptor.
60 64
61 The filenames you pass to these routines *must* be absolute. The reason 65 The filenames you pass to these routines *must* be absolute. The reason
96 Reads or writes "length" bytes from the specified "fh" and "offset" 100 Reads or writes "length" bytes from the specified "fh" and "offset"
97 into the scalar given by "data" and offset "dataoffset" and calls 101 into the scalar given by "data" and offset "dataoffset" and calls
98 the callback without the actual number of bytes read (or -1 on 102 the callback without the actual number of bytes read (or -1 on
99 error, just like the syscall). 103 error, just like the syscall).
100 104
101 Example: Read 15 bytes at offset 7 into scalar $buffer, strating at 105 Example: Read 15 bytes at offset 7 into scalar $buffer, starting at
102 offset 0 within the scalar: 106 offset 0 within the scalar:
103 107
104 aio_read $fh, 7, 15, $buffer, 0, sub { 108 aio_read $fh, 7, 15, $buffer, 0, sub {
105 $_[0] > 0 or die "read error: $!"; 109 $_[0] > 0 or die "read error: $!";
106 print "read $_[0] bytes: <$buffer>\n"; 110 print "read $_[0] bytes: <$buffer>\n";
107 }; 111 };
108 112
109 aio_readahead $fh,$offset,$length, $callback 113 aio_readahead $fh,$offset,$length, $callback
110 Asynchronously reads the specified byte range into the page cache, 114 Asynchronously reads the specified byte range into the page cache,
111 using the "readahead" syscall. If that syscall doesn't exist the 115 using the "readahead" syscall. If that syscall doesn't exist (likely
112 status will be -1 and $! is set to ENOSYS. 116 if your OS isn't Linux) the status will be -1 and $! is set to
117 ENOSYS.
113 118
114 readahead() populates the page cache with data from a file so that 119 readahead() populates the page cache with data from a file so that
115 subsequent reads from that file will not block on disk I/O. The 120 subsequent reads from that file will not block on disk I/O. The
116 $offset argument specifies the starting point from which data is to 121 $offset argument specifies the starting point from which data is to
117 be read and $length specifies the number of bytes to be read. I/O is 122 be read and $length specifies the number of bytes to be read. I/O is
187 Example: wait till there are no outstanding requests anymore: 192 Example: wait till there are no outstanding requests anymore:
188 193
189 IO::AIO::poll_wait, IO::AIO::poll_cb 194 IO::AIO::poll_wait, IO::AIO::poll_cb
190 while IO::AIO::nreqs; 195 while IO::AIO::nreqs;
191 196
197 IO::AIO::flush
198 Wait till all outstanding AIO requests have been handled.
199
200 Strictly equivalent to:
201
202 IO::AIO::poll_wait, IO::AIO::poll_cb
203 while IO::AIO::nreqs;
204
205 IO::AIO::poll
206 Waits until some requests have been handled.
207
208 Strictly equivalent to:
209
210 IO::AIO::poll_wait, IO::AIO::poll_cb
211 if IO::AIO::nreqs;
212
192 IO::AIO::min_parallel $nthreads 213 IO::AIO::min_parallel $nthreads
193 Set the minimum number of AIO threads to $nthreads. The default is 214 Set the minimum number of AIO threads to $nthreads. The default is
194 1, which means a single asynchronous operation can be done at one 215 1, which means a single asynchronous operation can be done at one
195 time (the number of outstanding operations, however, is unlimited). 216 time (the number of outstanding operations, however, is unlimited).
196 217

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines