… | |
… | |
12 | aio_unlink "/tmp/file", sub { }; |
12 | aio_unlink "/tmp/file", sub { }; |
13 | |
13 | |
14 | aio_read $fh, 30000, 1024, $buffer, 0, sub { |
14 | aio_read $fh, 30000, 1024, $buffer, 0, sub { |
15 | $_[0] > 0 or die "read error: $!"; |
15 | $_[0] > 0 or die "read error: $!"; |
16 | }; |
16 | }; |
|
|
17 | |
|
|
18 | # AnyEvent |
|
|
19 | open my $fh, "<&=" . IO::AIO::poll_fileno or die "$!"; |
|
|
20 | my $w = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { IO::AIO::poll_cb }); |
17 | |
21 | |
18 | # Event |
22 | # Event |
19 | Event->io (fd => IO::AIO::poll_fileno, |
23 | Event->io (fd => IO::AIO::poll_fileno, |
20 | poll => 'r', |
24 | poll => 'r', |
21 | cb => \&IO::AIO::poll_cb); |
25 | cb => \&IO::AIO::poll_cb); |
… | |
… | |
196 | |
200 | |
197 | aio_rmdir $pathname, $callback->($status) |
201 | aio_rmdir $pathname, $callback->($status) |
198 | Asynchronously rmdir (delete) a directory and call the callback with |
202 | Asynchronously rmdir (delete) a directory and call the callback with |
199 | the result code. |
203 | the result code. |
200 | |
204 | |
201 | aio_readdir $pathname $callback->($entries) |
205 | aio_readdir $pathname, $callback->($entries) |
202 | Unlike the POSIX call of the same name, "aio_readdir" reads an |
206 | Unlike the POSIX call of the same name, "aio_readdir" reads an |
203 | entire directory (i.e. opendir + readdir + closedir). The entries |
207 | entire directory (i.e. opendir + readdir + closedir). The entries |
204 | will not be sorted, and will NOT include the "." and ".." entries. |
208 | will not be sorted, and will NOT include the "." and ".." entries. |
205 | |
209 | |
206 | The callback a single argument which is either "undef" or an |
210 | The callback a single argument which is either "undef" or an |
… | |
… | |
241 | |
245 | |
242 | Then entires will be sorted into likely directories (everything |
246 | Then entires will be sorted into likely directories (everything |
243 | without a non-initial dot) and likely non-directories (everything |
247 | without a non-initial dot) and likely non-directories (everything |
244 | else). Then every entry + "/." will be "stat"'ed, likely directories |
248 | else). Then every entry + "/." will be "stat"'ed, likely directories |
245 | first. This is often faster because filesystems might detect the |
249 | first. This is often faster because filesystems might detect the |
246 | type of the entry without reading the inode data (e.g. ext2s |
250 | type of the entry without reading the inode data (e.g. ext2fs |
247 | filetype feature). If that succeeds, it assumes that the entry is a |
251 | filetype feature). If that succeeds, it assumes that the entry is a |
248 | directory or a symlink to directory (which will be checked |
252 | directory or a symlink to directory (which will be checked |
249 | seperately). |
253 | seperately). |
250 | |
254 | |
251 | If the known number of directories has been reached, the rest of the |
255 | If the known number of directories has been reached, the rest of the |