什么是凌空库请求队列的最大大小 [英] What is the Maximum Size of the Volley-Library Request-Queue

查看:117
本文介绍了什么是凌空库请求队列的最大大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用排球库在Android中,我想知道什么是队列的使用是允许的最大长度排球库。没有什么,我发现与此相关的。据我所知,你需要将网络请求添加到队列中,但我不知道什么是这一点,我可以把它放在队列并行最大尺寸。

 请求队列请求队列= Volley.newRequestQueue(本);
.... //将code座
requestQueue.add(jsonObjectRequest);
 

解决方案

你可能混淆了两件事情:

  • 在瓦亭队列大小
  • 在最大并行的网络请求

对于等待队列大小:

  / **请求实际上是走出去到网络上的队列。 * /
私人最终的PriorityBlockingQueue<请求<>> mNetworkQueue =
    新的PriorityBlockingQueue<请求<>>();
 

凌空使用它inself使用一个PriorityQueue为11默认容量的PriorityBlockingQueue。

 私有静态最终诠释DEFAULT_INITIAL_CAPACITY = 11;
...
公众的PriorityQueue(){
    这个(DEFAULT_INITIAL_CAPACITY,NULL);
}
 

对于最大的并行网络请求:

 请求队列请求队列= Volley.newRequestQueue(本);
 

将调用

 请求队列排队=新请求队列(新DiskBasedCache(cacheDir),网络);
 

和这个叫

 公共请求队列(缓存缓存,网络网){
        这(高速缓存,网络,DEFAULT_NETWORK_THREAD_POOL_SIZE);
    }
 

DEFAULT_NETWORK_THREAD_POOL_SIZE

 私有静态最终诠释DEFAULT_NETWORK_THREAD_POOL_SIZE = 4;
 

所以,在默认情况下有处理请求(在同一时间让最多4个请求)4并发线程。


TL;博士

瓦亭队列大小11,并且不能被改变;而最大并行网络请求是4,它可以与所述请求队列的构造被改变。

I am using Volley library in Android, I want to know what is maximum size of queue is allowed using Volley library. There is nothing I found related to this. As I know you need to add the network request to the queue but I don't know what is maximum size of this that I can put it on queue parallel.

RequestQueue requestQueue = Volley.newRequestQueue(this);
.... // block of code
requestQueue.add(jsonObjectRequest);

解决方案

You are probably confusing 2 things:

  • wating queue size
  • max parallel network requests

For waiting queue size:

/** The queue of requests that are actually going out to the network. */
private final PriorityBlockingQueue<Request<?>> mNetworkQueue =
    new PriorityBlockingQueue<Request<?>>();

Volley uses a PriorityBlockingQueue which inself uses a PriorityQueue with a default capacity of 11.

private static final int DEFAULT_INITIAL_CAPACITY = 11;
...
public PriorityQueue() {
    this(DEFAULT_INITIAL_CAPACITY, null);
}

For max parallel network requests:

RequestQueue requestQueue = Volley.newRequestQueue(this);

will call

RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network);

and this calls

public RequestQueue(Cache cache, Network network) {
        this(cache, network, DEFAULT_NETWORK_THREAD_POOL_SIZE);
    }

and DEFAULT_NETWORK_THREAD_POOL_SIZE is

private static final int DEFAULT_NETWORK_THREAD_POOL_SIZE = 4;

So by default there are 4 concurrent threads handling the requests (so max 4 request at the same time).


tl;dr

Wating queue size 11 and cannot be changed; while max parallel network requests are 4, which can be changed with the RequestQueue constructor.

这篇关于什么是凌空库请求队列的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆