… | |
… | |
26 | $req->cancel; # cancel request if still in queue |
26 | $req->cancel; # cancel request if still in queue |
27 | |
27 | |
28 | my $grp = aio_group sub { print "all stats done\n" }; |
28 | my $grp = aio_group sub { print "all stats done\n" }; |
29 | add $grp aio_stat "..." for ...; |
29 | add $grp aio_stat "..." for ...; |
30 | |
30 | |
31 | # AnyEvent integration |
31 | # AnyEvent integration (EV, Event, Glib, Tk, urxvt, pureperl...) |
32 | open my $fh, "<&=" . IO::AIO::poll_fileno or die "$!"; |
32 | open my $fh, "<&=" . IO::AIO::poll_fileno or die "$!"; |
33 | my $w = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { IO::AIO::poll_cb }); |
33 | my $w = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { IO::AIO::poll_cb }); |
|
|
34 | |
|
|
35 | # EV integration |
|
|
36 | my $w = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb; |
34 | |
37 | |
35 | # Event integration |
38 | # Event integration |
36 | Event->io (fd => IO::AIO::poll_fileno, |
39 | Event->io (fd => IO::AIO::poll_fileno, |
37 | poll => 'r', |
40 | poll => 'r', |
38 | cb => \&IO::AIO::poll_cb); |
41 | cb => \&IO::AIO::poll_cb); |
… | |
… | |
191 | use strict 'vars'; |
194 | use strict 'vars'; |
192 | |
195 | |
193 | use base 'Exporter'; |
196 | use base 'Exporter'; |
194 | |
197 | |
195 | BEGIN { |
198 | BEGIN { |
196 | our $VERSION = '2.51'; |
199 | our $VERSION = '2.6'; |
197 | |
200 | |
198 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
201 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
199 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
202 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
200 | aio_readlink aio_fsync aio_fdatasync aio_readahead aio_rename aio_link |
203 | aio_readlink aio_sync aio_fsync aio_fdatasync aio_readahead aio_rename aio_link |
201 | aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir |
204 | aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir |
202 | aio_chown aio_chmod aio_utime aio_truncate); |
205 | aio_chown aio_chmod aio_utime aio_truncate); |
203 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block)); |
206 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block)); |
204 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
207 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
205 | min_parallel max_parallel max_idle |
208 | min_parallel max_parallel max_idle |
… | |
… | |
890 | |
893 | |
891 | $grp |
894 | $grp |
892 | } |
895 | } |
893 | } |
896 | } |
894 | |
897 | |
|
|
898 | =item aio_sync $callback->($status) |
|
|
899 | |
|
|
900 | Asynchronously call sync and call the callback when finished. |
|
|
901 | |
895 | =item aio_fsync $fh, $callback->($status) |
902 | =item aio_fsync $fh, $callback->($status) |
896 | |
903 | |
897 | Asynchronously call fsync on the given filehandle and call the callback |
904 | Asynchronously call fsync on the given filehandle and call the callback |
898 | with the fsync result code. |
905 | with the fsync result code. |
899 | |
906 | |