Example usage for com.squareup.okhttp OkHttpClient setDispatcher

List of usage examples for com.squareup.okhttp OkHttpClient setDispatcher

Introduction

In this page you can find the example usage for com.squareup.okhttp OkHttpClient setDispatcher.

Prototype

public OkHttpClient setDispatcher(Dispatcher dispatcher) 

Source Link

Document

Sets the dispatcher used to set policy and execute asynchronous requests.

Usage

From source file:com.frostwire.http.HttpClient.java

License:Open Source License

private static OkHttpClient buildClient(Params params) {
    OkHttpClient c = Loader.DEFAULT_CLIENT.clone();
    ExecutorService pool = params.pool != null ? params.pool : c.getDispatcher().getExecutorService();

    Dispatcher d = new Dispatcher(pool);
    d.setMaxRequests(params.maxRequests);
    d.setMaxRequestsPerHost(params.maxRequestsPerHost);
    c.setDispatcher(d);

    return c;/* w w  w .j  av  a2s.  co  m*/
}