… | |
… | |
780 | |
780 | |
781 | 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 |
782 | regularly. Returns the number of events processed. Returns immediately |
782 | regularly. Returns the number of events processed. Returns immediately |
783 | when no events are outstanding. |
783 | when no events are outstanding. |
784 | |
784 | |
|
|
785 | If not all requests were processed for whatever reason, the filehandle |
|
|
786 | will still be ready when C<poll_cb> returns. |
|
|
787 | |
785 | Example: Install an Event watcher that automatically calls |
788 | Example: Install an Event watcher that automatically calls |
786 | IO::AIO::poll_cb with high priority: |
789 | IO::AIO::poll_cb with high priority: |
787 | |
790 | |
788 | Event->io (fd => IO::AIO::poll_fileno, |
791 | Event->io (fd => IO::AIO::poll_fileno, |
789 | poll => 'r', async => 1, |
792 | poll => 'r', async => 1, |
790 | 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 }); |
791 | |
810 | |
792 | =item IO::AIO::poll_wait |
811 | =item IO::AIO::poll_wait |
793 | |
812 | |
794 | 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 |
795 | 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 |
… | |
… | |
855 | This module automatically runs C<max_parallel 0> at program end, to ensure |
874 | This module automatically runs C<max_parallel 0> at program end, to ensure |
856 | that all threads are killed and that there are no outstanding requests. |
875 | that all threads are killed and that there are no outstanding requests. |
857 | |
876 | |
858 | Under normal circumstances you don't need to call this function. |
877 | Under normal circumstances you don't need to call this function. |
859 | |
878 | |
860 | =item $oldnreqs = IO::AIO::max_outstanding $nreqs |
879 | =item $oldmaxreqs = IO::AIO::max_outstanding $maxreqs |
861 | |
880 | |
862 | [REMOVED] |
881 | This is a very bad function to use in interactive programs because it |
|
|
882 | blocks, and a bad way to reduce concurrency because it is inexact: Better |
|
|
883 | use an C<aio_group> together with a feed callback. |
863 | |
884 | |
864 | Pre-2.x versions used max_outstanding for a crude request queue length limit. |
|
|
865 | |
|
|
866 | In 2.x+ you are advised to use a group and a feeder to limit |
|
|
867 | concurrency. The max_outstanding feature ran very unstable (endless |
|
|
868 | recursions causing segfaults, bad interaction with groups etc.) and was |
|
|
869 | removed. |
|
|
870 | |
|
|
871 | I am deeply sorry, but I am still on the hunt for a good limiting interface. |
|
|
872 | |
|
|
873 | Original description was as follows: |
|
|
874 | |
|
|
875 | Sets the maximum number of outstanding requests to C<$nreqs>. If you try |
885 | Sets the maximum number of outstanding requests to C<$nreqs>. If you |
876 | to queue up more than this number of requests, the caller will block until |
886 | to queue up more than this number of requests, the next call to the |
877 | some requests have been handled. |
887 | C<poll_cb> (and C<poll_some> and other functions calling C<poll_cb>) |
|
|
888 | function will block until the limit is no longer exceeded. |
|
|
889 | |
|
|
890 | The default value is very large, so there is no practical limit on the |
|
|
891 | number of outstanding requests. |
|
|
892 | |
|
|
893 | You can still queue as many requests as you want. Therefore, |
|
|
894 | C<max_oustsanding> is mainly useful in simple scripts (with low values) or |
|
|
895 | as a stop gap to shield against fatal memory overflow (with large values). |
878 | |
896 | |
879 | =back |
897 | =back |
880 | |
898 | |
881 | =cut |
899 | =cut |
882 | |
900 | |