public class RouteSpecificPool
extends java.lang.Object
ConnPoolByRoute
.
The methods in this class are unsynchronized. It is expected that the
containing pool takes care of synchronization.Modifier and Type | Field and Description |
---|---|
protected java.util.LinkedList |
freeEntries
The list of free entries.
|
protected int |
maxEntries
the maximum number of entries allowed for this pool
|
protected int |
numEntries
The number of created entries.
|
protected HttpRoute |
route
The route this pool is for.
|
protected java.util.LinkedList |
waitingThreads
The list of threads waiting for this pool.
|
Constructor and Description |
---|
RouteSpecificPool(HttpRoute route,
int maxEntries)
Creates a new route-specific pool.
|
Modifier and Type | Method and Description |
---|---|
BasicPoolEntry |
allocEntry(java.lang.Object state)
Obtains a free entry from this pool, if one is available.
|
void |
createdEntry(BasicPoolEntry entry)
Indicates creation of an entry for this pool.
|
boolean |
deleteEntry(BasicPoolEntry entry)
Deletes an entry from this pool.
|
void |
dropEntry()
Forgets about an entry from this pool.
|
void |
freeEntry(BasicPoolEntry entry)
Returns an allocated entry to this pool.
|
int |
getCapacity()
Return remaining capacity of this pool
|
int |
getEntryCount()
Obtains the number of entries.
|
int |
getMaxEntries()
Obtains the maximum number of entries allowed for this pool.
|
HttpRoute |
getRoute()
Obtains the route for which this pool is specific.
|
boolean |
hasThread()
Checks whether there is a waiting thread in this pool.
|
boolean |
isUnused()
Indicates whether this pool is unused.
|
WaitingThread |
nextThread()
Returns the next thread in the queue.
|
void |
queueThread(WaitingThread wt)
Adds a waiting thread.
|
void |
removeThread(WaitingThread wt)
Removes a waiting thread, if it is queued.
|
protected final HttpRoute route
protected final int maxEntries
protected final java.util.LinkedList freeEntries
protected final java.util.LinkedList waitingThreads
protected int numEntries
public RouteSpecificPool(HttpRoute route, int maxEntries)
route
- the route for which to poolmaxEntries
- the maximum number of entries allowed for this poolpublic final HttpRoute getRoute()
public final int getMaxEntries()
public boolean isUnused()
true
if this pool is unused,
false
otherwisepublic int getCapacity()
public final int getEntryCount()
public BasicPoolEntry allocEntry(java.lang.Object state)
null
if there is nonepublic void freeEntry(BasicPoolEntry entry)
entry
- the entry obtained from allocEntry
or presented to createdEntry
public void createdEntry(BasicPoolEntry entry)
freeEntry
.entry
- the entry that was created for this poolpublic boolean deleteEntry(BasicPoolEntry entry)
entry
- the entry to delete from this pooltrue
if the entry was found and deleted, or
false
if the entry was not foundpublic void dropEntry()
allocated
from this pool has been lost and will not be returned.public void queueThread(WaitingThread wt)
wt
- the waiting threadpublic boolean hasThread()
true
if there is a waiting thread,
false
otherwisepublic WaitingThread nextThread()
null
if there is nonepublic void removeThread(WaitingThread wt)
wt
- the waiting thread