… | |
… | |
134 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
134 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
135 | aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move |
135 | aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move |
136 | aio_group aio_nop); |
136 | aio_group aio_nop); |
137 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); |
137 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); |
138 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
138 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
139 | min_parallel max_parallel max_outstanding nreqs); |
139 | min_parallel max_parallel nreqs); |
140 | |
140 | |
141 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
141 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
142 | |
142 | |
143 | require XSLoader; |
143 | require XSLoader; |
144 | XSLoader::load ("IO::AIO", $VERSION); |
144 | XSLoader::load ("IO::AIO", $VERSION); |
… | |
… | |
682 | =item * They can also can also be added to other IO::AIO::GRP objects. |
682 | =item * They can also can also be added to other IO::AIO::GRP objects. |
683 | |
683 | |
684 | =item * You must not add requests to a group from within the group callback (or |
684 | =item * You must not add requests to a group from within the group callback (or |
685 | any later time). |
685 | any later time). |
686 | |
686 | |
687 | =item * This does not harmonise well with C<max_outstanding>, so best do |
|
|
688 | not combine C<aio_group> with it. Groups and feeders are recommended for |
|
|
689 | this kind of concurrency-limiting. |
|
|
690 | |
|
|
691 | =back |
687 | =back |
692 | |
688 | |
693 | Their lifetime, simplified, looks like this: when they are empty, they |
689 | Their lifetime, simplified, looks like this: when they are empty, they |
694 | will finish very quickly. If they contain only requests that are in the |
690 | will finish very quickly. If they contain only requests that are in the |
695 | C<done> state, they will also finish. Otherwise they will continue to |
691 | C<done> state, they will also finish. Otherwise they will continue to |
… | |
… | |
784 | |
780 | |
785 | Process all outstanding events on the result pipe. You have to call this |
781 | Process all outstanding events on the result pipe. You have to call this |
786 | regularly. Returns the number of events processed. Returns immediately |
782 | regularly. Returns the number of events processed. Returns immediately |
787 | when no events are outstanding. |
783 | when no events are outstanding. |
788 | |
784 | |
|
|
785 | If not all requests were processed for whatever reason, the filehandle |
|
|
786 | will still be ready when C<poll_cb> returns. |
|
|
787 | |
789 | Example: Install an Event watcher that automatically calls |
788 | Example: Install an Event watcher that automatically calls |
790 | IO::AIO::poll_cb with high priority: |
789 | IO::AIO::poll_cb with high priority: |
791 | |
790 | |
792 | Event->io (fd => IO::AIO::poll_fileno, |
791 | Event->io (fd => IO::AIO::poll_fileno, |
793 | poll => 'r', async => 1, |
792 | poll => 'r', async => 1, |
794 | cb => \&IO::AIO::poll_cb); |
793 | cb => \&IO::AIO::poll_cb); |
|
|
794 | |
|
|
795 | =item IO::AIO::poll_some $max_requests |
|
|
796 | |
|
|
797 | Similar to C<poll_cb>, but only processes up to C<$max_requests> requests |
|
|
798 | at a time. |
|
|
799 | |
|
|
800 | Useful if you want to ensure some level of interactiveness when perl is |
|
|
801 | not fast enough to process all requests in time. |
|
|
802 | |
|
|
803 | Example: Install an Event watcher that automatically calls |
|
|
804 | IO::AIO::poll_some with low priority, to ensure that other parts of the |
|
|
805 | program get the CPU sometimes even under high AIO load. |
|
|
806 | |
|
|
807 | Event->io (fd => IO::AIO::poll_fileno, |
|
|
808 | poll => 'r', nice => 1, |
|
|
809 | cb => sub { IO::AIO::poll_some 256 }); |
795 | |
810 | |
796 | =item IO::AIO::poll_wait |
811 | =item IO::AIO::poll_wait |
797 | |
812 | |
798 | Wait till the result filehandle becomes ready for reading (simply does a |
813 | Wait till the result filehandle becomes ready for reading (simply does a |
799 | C<select> on the filehandle. This is useful if you want to synchronously wait |
814 | C<select> on the filehandle. This is useful if you want to synchronously wait |
… | |
… | |
861 | |
876 | |
862 | Under normal circumstances you don't need to call this function. |
877 | Under normal circumstances you don't need to call this function. |
863 | |
878 | |
864 | =item $oldnreqs = IO::AIO::max_outstanding $nreqs |
879 | =item $oldnreqs = IO::AIO::max_outstanding $nreqs |
865 | |
880 | |
866 | [DEPRECATED] |
881 | [REMOVED] |
867 | |
882 | |
|
|
883 | Pre-2.x versions used max_outstanding for a crude request queue length limit. |
|
|
884 | |
|
|
885 | In 2.x+ you are advised to use a group and a feeder to limit |
|
|
886 | concurrency. The max_outstanding feature ran very unstable (endless |
|
|
887 | recursions causing segfaults, bad interaction with groups etc.) and was |
|
|
888 | removed. |
|
|
889 | |
|
|
890 | I am deeply sorry, but I am still on the hunt for a good limiting interface. |
|
|
891 | |
|
|
892 | Original description was as follows: |
|
|
893 | |
868 | Sets the maximum number of outstanding requests to C<$nreqs>. If you |
894 | Sets the maximum number of outstanding requests to C<$nreqs>. If you try |
869 | try to queue up more than this number of requests, the caller will block until |
895 | to queue up more than this number of requests, the caller will block until |
870 | some requests have been handled. |
896 | some requests have been handled. |
871 | |
|
|
872 | The default is very large, so normally there is no practical limit. If you |
|
|
873 | queue up many requests in a loop it often improves speed if you set |
|
|
874 | this to a relatively low number, such as C<100>. |
|
|
875 | |
|
|
876 | This function does not work well together with C<aio_group>'s, and their |
|
|
877 | feeder interface is better suited to limiting concurrency, so do not use |
|
|
878 | this function. |
|
|
879 | |
|
|
880 | Under normal circumstances you don't need to call this function. |
|
|
881 | |
897 | |
882 | =back |
898 | =back |
883 | |
899 | |
884 | =cut |
900 | =cut |
885 | |
901 | |