… | |
… | |
33 | syscall has been executed asynchronously. |
33 | syscall has been executed asynchronously. |
34 | |
34 | |
35 | All functions that expect a filehandle will also accept a file |
35 | All functions that expect a filehandle will also accept a file |
36 | descriptor. |
36 | descriptor. |
37 | |
37 | |
|
|
38 | The filenames you pass to these routines *must* be absolute. The reason |
|
|
39 | is that at the time the request is being executed, the current working |
|
|
40 | directory could have changed. Alternatively, you can make sure that you |
|
|
41 | never change the current working directory. |
|
|
42 | |
38 | Linux::AIO::min_parallel $nthreads |
43 | Linux::AIO::min_parallel $nthreads |
39 | Set the minimum number of AIO threads to $nthreads. The default is |
44 | Set the minimum number of AIO threads to $nthreads. The default is |
40 | 1, which means a single asynchronous operation can be done at one |
45 | 1, which means a single asynchronous operation can be done at one |
41 | time (the number of outstanding operations, however, is unlimited). |
46 | time (the number of outstanding operations, however, is unlimited). |
42 | |
47 | |
… | |
… | |
87 | Linux::AIO::nreqs |
92 | Linux::AIO::nreqs |
88 | Returns the number of requests currently outstanding. |
93 | Returns the number of requests currently outstanding. |
89 | |
94 | |
90 | Example: wait till there are no outstanding requests anymore: |
95 | Example: wait till there are no outstanding requests anymore: |
91 | |
96 | |
92 | Linux::AIO::poll_wait while Linux::AIO::nreqs; |
97 | Linux::AIO::poll_wait, Linux::AIO::poll_cb |
|
|
98 | while Linux::AIO::nreqs; |
93 | |
99 | |
94 | aio_open $pathname, $flags, $mode, $callback |
100 | aio_open $pathname, $flags, $mode, $callback |
95 | Asynchronously open or create a file and call the callback with the |
101 | Asynchronously open or create a file and call the callback with the |
96 | filedescriptor (NOT a perl filehandle, sorry for that, but watch |
102 | filedescriptor (NOT a perl filehandle, sorry for that, but watch |
97 | out, this might change in the future). |
103 | out, this might change in the future). |
98 | |
104 | |
|
|
105 | The pathname passed to "aio_open" must be absolute. See API NOTES, |
|
|
106 | above, for an explanation. |
|
|
107 | |
99 | The $mode argument is a bitmask. See the "Fcntl" module for a list. |
108 | The $mode argument is a bitmask. See the "Fcntl" module for a list. |
100 | They are the same as used in "sysopen". |
109 | They are the same as used in "sysopen". |
101 | |
110 | |
102 | Example: |
111 | Example: |
103 | |
112 | |
104 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
113 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
105 | if ($_[0] >= 0) { |
114 | if ($_[0] >= 0) { |
106 | open my $fh, "<&$_[0]"; # create a copy for perl |
115 | open my $fh, "<&=$_[0]"; |
107 | aio_close $_[0], sub { }; # close the aio handle |
|
|
108 | print "open successful, fh is $fh\n"; |
116 | print "open successful, fh is $fh\n"; |
109 | ... |
117 | ... |
110 | } else { |
118 | } else { |
111 | die "open failed: $!\n"; |
119 | die "open failed: $!\n"; |
112 | } |
120 | } |
… | |
… | |
149 | aio_lstat $fh, $callback |
157 | aio_lstat $fh, $callback |
150 | Works like perl's "stat" or "lstat" in void context. The callback |
158 | Works like perl's "stat" or "lstat" in void context. The callback |
151 | will be called after the stat and the results will be available |
159 | will be called after the stat and the results will be available |
152 | using "stat _" or "-s _" etc... |
160 | using "stat _" or "-s _" etc... |
153 | |
161 | |
|
|
162 | The pathname passed to "aio_stat" must be absolute. See API NOTES, |
|
|
163 | above, for an explanation. |
|
|
164 | |
154 | Currently, the stats are always 64-bit-stats, i.e. instead of |
165 | Currently, the stats are always 64-bit-stats, i.e. instead of |
155 | returning an error when stat'ing a large file, the results will be |
166 | returning an error when stat'ing a large file, the results will be |
156 | silently truncated unless perl itself is compiled with large file |
167 | silently truncated unless perl itself is compiled with large file |
157 | support. |
168 | support. |
158 | |
169 | |
… | |
… | |
180 | webserver for many years now. |
191 | webserver for many years now. |
181 | |
192 | |
182 | - aio_open gives a fd, but all other functions expect a perl filehandle. |
193 | - aio_open gives a fd, but all other functions expect a perl filehandle. |
183 | |
194 | |
184 | SEE ALSO |
195 | SEE ALSO |
185 | Coro. |
196 | Coro, IO::AIO. |
186 | |
197 | |
187 | AUTHOR |
198 | AUTHOR |
188 | Marc Lehmann <schmorp@schmorp.de> |
199 | Marc Lehmann <schmorp@schmorp.de> |
189 | http://home.schmorp.de/ |
200 | http://home.schmorp.de/ |
190 | |
201 | |