… | |
… | |
190 | use strict 'vars'; |
190 | use strict 'vars'; |
191 | |
191 | |
192 | use base 'Exporter'; |
192 | use base 'Exporter'; |
193 | |
193 | |
194 | BEGIN { |
194 | BEGIN { |
195 | our $VERSION = '2.31'; |
195 | our $VERSION = '2.32'; |
196 | |
196 | |
197 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
197 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
198 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
198 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
199 | aio_readlink aio_fsync aio_fdatasync aio_readahead aio_rename aio_link |
199 | aio_readlink aio_fsync aio_fdatasync aio_readahead aio_rename aio_link |
200 | aio_move aio_copy aio_group aio_nop aio_mknod aio_load); |
200 | aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree); |
201 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block)); |
201 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block)); |
202 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
202 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
203 | min_parallel max_parallel max_idle |
203 | min_parallel max_parallel max_idle |
204 | nreqs nready npending nthreads |
204 | nreqs nready npending nthreads |
205 | max_poll_time max_poll_reqs); |
205 | max_poll_time max_poll_reqs); |
… | |
… | |
722 | |
722 | |
723 | $grp |
723 | $grp |
724 | } |
724 | } |
725 | } |
725 | } |
726 | |
726 | |
|
|
727 | =item aio_rmtree $path, $callback->($status) |
|
|
728 | |
|
|
729 | Delete a directory tree starting (and including) C<$path>, return the status of the final C<rmdir> only. |
|
|
730 | This is a composite request that uses C<aio_scandir> to recurse into and rmdir directories, and |
|
|
731 | unlink everything else. |
|
|
732 | |
|
|
733 | =cut |
|
|
734 | |
|
|
735 | sub aio_rmtree; |
|
|
736 | sub aio_rmtree { |
|
|
737 | aio_block { |
|
|
738 | my ($path, $cb) = @_; |
|
|
739 | |
|
|
740 | my $pri = aioreq_pri; |
|
|
741 | my $grp = aio_group $cb; |
|
|
742 | |
|
|
743 | aioreq_pri $pri; |
|
|
744 | add $grp aio_scandir $path, 0, sub { |
|
|
745 | my ($dirs, $nondirs) = @_; |
|
|
746 | |
|
|
747 | my $dirgrp = aio_group sub { |
|
|
748 | add $grp aio_rmdir $path, sub { |
|
|
749 | $grp->result ($_[0]); |
|
|
750 | }; |
|
|
751 | }; |
|
|
752 | |
|
|
753 | (aioreq_pri $pri), add $dirgrp aio_rmtree "$path/$_" for @$dirs; |
|
|
754 | (aioreq_pri $pri), add $dirgrp aio_unlink "$path/$_" for @$nondirs; |
|
|
755 | |
|
|
756 | add $grp $dirgrp; |
|
|
757 | }; |
|
|
758 | |
|
|
759 | $grp |
|
|
760 | } |
|
|
761 | } |
|
|
762 | |
727 | =item aio_fsync $fh, $callback->($status) |
763 | =item aio_fsync $fh, $callback->($status) |
728 | |
764 | |
729 | Asynchronously call fsync on the given filehandle and call the callback |
765 | Asynchronously call fsync on the given filehandle and call the callback |
730 | with the fsync result code. |
766 | with the fsync result code. |
731 | |
767 | |