Methods Summary |
---|
synchronized boolean | cacheConnection(org.apache.http.HttpHost host, Connection connection)Caches connection, if there is room.
boolean ret = false;
if (HttpLog.LOGV) {
HttpLog.v("IdleCache size " + mCount + " host " + host);
}
if (mCount < IDLE_CACHE_MAX) {
long time = SystemClock.uptimeMillis();
for (int i = 0; i < IDLE_CACHE_MAX; i++) {
Entry entry = mEntries[i];
if (entry.mHost == null) {
entry.mHost = host;
entry.mConnection = connection;
entry.mTimeout = time + TIMEOUT;
mCount++;
if (HttpLog.LOGV) mCached++;
ret = true;
if (mThread == null) {
mThread = new IdleReaper();
mThread.start();
}
break;
}
}
}
return ret;
|
synchronized void | clear()
for (int i = 0; mCount > 0 && i < IDLE_CACHE_MAX; i++) {
Entry entry = mEntries[i];
if (entry.mHost != null) {
entry.mHost = null;
entry.mConnection.closeConnection();
entry.mConnection = null;
mCount--;
}
}
|
private synchronized void | clearIdle()
if (mCount > 0) {
long time = SystemClock.uptimeMillis();
for (int i = 0; i < IDLE_CACHE_MAX; i++) {
Entry entry = mEntries[i];
if (entry.mHost != null && time > entry.mTimeout) {
entry.mHost = null;
entry.mConnection.closeConnection();
entry.mConnection = null;
mCount--;
}
}
}
|
synchronized Connection | getConnection(org.apache.http.HttpHost host)
Connection ret = null;
if (mCount > 0) {
for (int i = 0; i < IDLE_CACHE_MAX; i++) {
Entry entry = mEntries[i];
HttpHost eHost = entry.mHost;
if (eHost != null && eHost.equals(host)) {
ret = entry.mConnection;
entry.mHost = null;
entry.mConnection = null;
mCount--;
if (HttpLog.LOGV) mReused++;
break;
}
}
}
return ret;
|