… | |
… | |
61 | =cut |
61 | =cut |
62 | |
62 | |
63 | package IO::AIO; |
63 | package IO::AIO; |
64 | |
64 | |
65 | no warnings; |
65 | no warnings; |
|
|
66 | use strict 'vars'; |
66 | |
67 | |
67 | use base 'Exporter'; |
68 | use base 'Exporter'; |
68 | |
69 | |
69 | use Fcntl (); |
|
|
70 | |
|
|
71 | BEGIN { |
70 | BEGIN { |
72 | $VERSION = '1.8'; |
71 | our $VERSION = '1.8'; |
73 | |
72 | |
74 | @EXPORT = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
73 | our @EXPORT = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
75 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
74 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
76 | aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move); |
75 | aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move); |
77 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel |
76 | our @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel max_outstanding nreqs); |
78 | max_outstanding nreqs); |
|
|
79 | |
77 | |
80 | require XSLoader; |
78 | require XSLoader; |
81 | XSLoader::load IO::AIO, $VERSION; |
79 | XSLoader::load ("IO::AIO", $VERSION); |
82 | } |
80 | } |
83 | |
81 | |
84 | =head1 FUNCTIONS |
82 | =head1 FUNCTIONS |
85 | |
83 | |
86 | =head2 AIO FUNCTIONS |
84 | =head2 AIO FUNCTIONS |
… | |
… | |
191 | |
189 | |
192 | sub aio_move($$$) { |
190 | sub aio_move($$$) { |
193 | my ($src, $dst, $cb) = @_; |
191 | my ($src, $dst, $cb) = @_; |
194 | |
192 | |
195 | aio_rename $src, $dst, sub { |
193 | aio_rename $src, $dst, sub { |
196 | if ($_[0] && $! == Errno::EXDEV) { |
194 | if ($_[0] && $! == EXDEV) { |
197 | aio_open $src, O_RDONLY, 0, sub { |
195 | aio_open $src, O_RDONLY, 0, sub { |
198 | if (my $src_fh = $_[0]) { |
196 | if (my $src_fh = $_[0]) { |
199 | my @stat = stat $src_fh; |
197 | my @stat = stat $src_fh; |
200 | |
198 | |
201 | aio_open $dst, O_WRONLY, 0200, sub { |
199 | aio_open $dst, O_WRONLY, 0200, sub { |