--- IO-AIO/AIO.pm 2005/08/30 15:45:10 1.40 +++ IO-AIO/AIO.pm 2006/02/16 16:38:57 1.48 @@ -17,6 +17,10 @@ $_[0] > 0 or die "read error: $!"; }; + # AnyEvent + open my $fh, "<&=" . IO::AIO::poll_fileno or die "$!"; + my $w = AnyEvent->io (fh => $fh, poll => 'r', cb => sub { IO::AIO::poll_cb }); + # Event Event->io (fd => IO::AIO::poll_fileno, poll => 'r', @@ -65,7 +69,7 @@ use Fcntl (); BEGIN { - $VERSION = 1.6; + $VERSION = '1.72'; @EXPORT = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink @@ -235,7 +239,7 @@ Asynchronously rmdir (delete) a directory and call the callback with the result code. -=item aio_readdir $pathname $callback->($entries) +=item aio_readdir $pathname, $callback->($entries) Unlike the POSIX call of the same name, C reads an entire directory (i.e. opendir + readdir + closedir). The entries will not be @@ -280,7 +284,7 @@ non-initial dot) and likely non-directories (everything else). Then every entry + C will be C'ed, likely directories first. This is often faster because filesystems might detect the type of the entry without -reading the inode data (e.g. ext2s filetype feature). If that succeeds, +reading the inode data (e.g. ext2fs filetype feature). If that succeeds, it assumes that the entry is a directory or a symlink to directory (which will be checked seperately). @@ -296,7 +300,7 @@ # stat once aio_stat $path, sub { - $cb->() if $_[0]; + return $cb->() if $_[0]; my $hash1 = join ":", (stat _)[0,1,3,7,9]; # read the directory entries @@ -317,7 +321,7 @@ # if nlink == 2, we are finished # on non-posix-fs's, we rely on nlink < 2 $ndirs = (stat _)[3] - 2 - or $cb->([], $entries); + or return $cb->([], $entries); } # sort into likely dirs and likely nondirs @@ -343,7 +347,7 @@ # finished undef $statcb; undef $schedcb; - $cb->(\@dirs, \@nondirs); + $cb->(\@dirs, \@nondirs) if $cb; undef $cb; } };