Wait until a free request slot is available and call the callback with the
resolver object.
A request slot is used each time a request is actually sent to the
nameservers: There are never more than C<max_outstanding> of them.
Although you can submit more requests (they will simply be queued until
a request slot becomes available), sometimes, usually for rate-limiting
purposes, it is useful to instead wait for a slot before generating the
request (or simply to know when the request load is low enough so one can
submit requests again).
This is what this method does: The callback will be called when submitting
a DNS request will not result in that request being queued. The callback
may or may not generate any requests in response.
Note that the callback will only be invoked when the request queue is
empty, so this does not play well if somebody else keeps the request queue
full at all times.
=cut
sub wait_for_slot {
my ($self, $cb) = @_;
push @{ $self->{wait} }, $cb;
$self->_scheduler;
}
use AnyEvent::Socket (); # circular dependency, so do not import anything and do it at the end
1;
=back
=head1 AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
=cut
=14=
THE END |