A connection sub-pool for a specific route, used by com.good.gd.apache.http.impl.conn.tsccm.ConnPoolByRoute. More...
The methods in this class are unsynchronized. It is expected that the containing pool takes care of synchronization.
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
RouteSpecificPool (HttpRoute route, int maxEntries) | |
Creates a new route-specific pool. More... | |
final HttpRoute | getRoute () |
Obtains the route for which this pool is specific. More... | |
final int | getMaxEntries () |
Obtains the maximum number of entries allowed for this pool. More... | |
boolean | isUnused () |
Indicates whether this pool is unused. More... | |
int | getCapacity () |
Return remaining capacity of this pool. More... | |
final int | getEntryCount () |
Obtains the number of entries. More... | |
BasicPoolEntry | allocEntry (final Object state) |
Obtains a free entry from this pool, if one is available. More... | |
void | freeEntry (BasicPoolEntry entry) |
Returns an allocated entry to this pool. More... | |
void | createdEntry (BasicPoolEntry entry) |
Indicates creation of an entry for this pool. More... | |
boolean | deleteEntry (BasicPoolEntry entry) |
Deletes an entry from this pool. More... | |
void | dropEntry () |
Forgets about an entry from this pool. More... | |
void | queueThread (WaitingThread wt) |
Adds a waiting thread. More... | |
boolean | hasThread () |
Checks whether there is a waiting thread in this pool. More... | |
WaitingThread | nextThread () |
Returns the next thread in the queue. More... | |
void | removeThread (WaitingThread wt) |
Removes a waiting thread, if it is queued. More... | |
Protected Attributes | |
final HttpRoute | route |
The route this pool is for. More... | |
final int | maxEntries |
the maximum number of entries allowed for this pool | |
final LinkedList< BasicPoolEntry > | freeEntries |
The list of free entries. More... | |
final Queue< WaitingThread > | waitingThreads |
The list of threads waiting for this pool. More... | |
int | numEntries |
The number of created entries. More... | |
RouteSpecificPool | ( | HttpRoute | route, |
int | maxEntries | ||
) |
route | the route for which to pool |
maxEntries | the maximum number of entries allowed for this pool |
final HttpRoute getRoute | ( | ) |
final int getMaxEntries | ( | ) |
boolean isUnused | ( | ) |
A pool is unused if there is neither an entry nor a waiting thread. All entries count, not only the free but also the allocated ones.
true
if this pool is unused, false
otherwise int getCapacity | ( | ) |
final int getEntryCount | ( | ) |
This includes not only the free entries, but also those that have been created and are currently issued to an application.
BasicPoolEntry allocEntry | ( | final Object | state | ) |
null
if there is none void freeEntry | ( | BasicPoolEntry | entry | ) |
entry | the entry obtained from allocEntry or presented to createdEntry |
void createdEntry | ( | BasicPoolEntry | entry | ) |
The entry will not be added to the list of free entries, it is only recognized as belonging to this pool now. It can then be passed to freeEntry .
entry | the entry that was created for this pool |
boolean deleteEntry | ( | BasicPoolEntry | entry | ) |
Only entries that are currently free in this pool can be deleted. Allocated entries can not be deleted.
entry | the entry to delete from this pool |
true
if the entry was found and deleted, or false
if the entry was not found void dropEntry | ( | ) |
This method is used to indicate that an entry allocated from this pool has been lost and will not be returned.
void queueThread | ( | WaitingThread | wt | ) |
This pool makes no attempt to match waiting threads with pool entries. It is the caller's responsibility to check that there is no entry before adding a waiting thread.
wt | the waiting thread |
boolean hasThread | ( | ) |
true
if there is a waiting thread, false
otherwise WaitingThread nextThread | ( | ) |
null
if there is none void removeThread | ( | WaitingThread | wt | ) |
wt | the waiting thread |
|
protected |
|
protected |
This list is managed LIFO, to increase idle times and allow for closing connections that are not really needed.
|
protected |
|
protected |