Example usage for org.apache.http.nio.concurrent BasicFuture BasicFuture

List of usage examples for org.apache.http.nio.concurrent BasicFuture BasicFuture

Introduction

In this page you can find the example usage for org.apache.http.nio.concurrent BasicFuture BasicFuture.

Prototype

public BasicFuture(final FutureCallback<T> callback) 

Source Link

Usage

From source file:org.apache.http.impl.nio.conn.PoolingClientConnectionManager.java

public Future<ManagedClientConnection> leaseConnection(final HttpRoute route, final Object state,
        final long timeout, final TimeUnit tunit, final FutureCallback<ManagedClientConnection> callback) {
    if (route == null) {
        throw new IllegalArgumentException("HTTP route may not be null");
    }//from   w w  w  .j a  va  2  s  .c o  m
    if (tunit == null) {
        throw new IllegalArgumentException("Time unit may not be null");
    }
    if (this.log.isDebugEnabled()) {
        this.log.debug("Connection request: route[" + route + "][state: " + state + "]");
        PoolStats totals = this.pool.getTotalStats();
        PoolStats stats = this.pool.getStats(route);
        this.log.debug("Total: " + totals);
        this.log.debug("Route [" + route + "]: " + stats);
    }
    BasicFuture<ManagedClientConnection> future = new BasicFuture<ManagedClientConnection>(callback);
    this.pool.lease(route, state, timeout, tunit, new InternalPoolEntryCallback(future));
    if (this.log.isDebugEnabled()) {
        if (!future.isDone()) {
            this.log.debug("Connection could not be allocated immediately: " + "route[" + route + "][state: "
                    + state + "]");
        }
    }
    return future;
}