2014-12-23 9 views
2

일부 AQuery 코드 here을 검토 중이었고 AQuery에서 네트워크 연결 수를 수정할 수있는 방법이 있다는 것을 알았습니다.Retrofit에서 최대 네트워크 연결 수를 설정하는 방법

개장시이 작업을 수행 할 수있는 방법이 있습니까? 그리고 개장시 기본값은 무엇입니까? 개조의 예를 들어 연결

/* Settings of Image */ 
//set the max number of concurrent network connections, default is 4 
AjaxCallback.setNetworkLimit(8); 

//set the max number of icons (image width <= 50) to be cached in memory, default is 20 
BitmapAjaxCallback.setIconCacheLimit(50); 

//set the max number of images (image width > 50) to be cached in memory, default is 20 
BitmapAjaxCallback.setCacheLimit(50); 

aq = new AQuery(context); 

답변

3

기본 번호는 Executor

당신은 네트워크 연결을 제한 할 수 있습니다

에 공급되는 다소 온 디맨드, 즉 새로운 스레드가 각각의 새로운 Runnable (연결)에 재사용/생성된다 번호를 제한하여 Thread. 당신은 빌드 할 때 당신의 RestAdapter 수행

restAdapterBuilder.setExecutors(Executors.newCachedThreadPool(numberOfConnections), new MainThreadExecutor()); 

또는

restAdapterBuilder.setExecutors(Executors.newFixedThreadPool(numberOfConnections), new MainThreadExecutor()); 

이 AQuery가 연결 수를 제한하기 위해 무엇을 정확히 동일합니다.

Executors 자세한 내용은

을 참조하십시오.