|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.openejb.util.Pool<T>
public class Pool<T>
Any successful pop() call requires a corresponding push() or discard() call.
A pop() call that returns null is considered successful. A null indicates that the calling code has a permit to create a poolable object and callpush(Object)
. This is the only situation in which that method
may be called.
To simply fill the pool without a corresponding pop(), the add() method
must be used. This method will attempt to aquire a permit to add to the pool.
Nested Class Summary | |
---|---|
static class |
Pool.Builder<T>
|
class |
Pool.Entry
|
static class |
Pool.Event
|
static class |
Pool.HardReference<T>
|
static interface |
Pool.Supplier<T>
|
Constructor Summary | |
---|---|
Pool(int max,
int min,
boolean strict)
|
|
Pool(int max,
int min,
boolean strict,
long maxAge,
long idleTimeout,
long sweepInterval,
java.util.concurrent.Executor executor,
Pool.Supplier<T> supplier,
boolean replaceAged,
double maxAgeOffset,
boolean garbageCollection,
boolean replaceFlushed)
|
Method Summary | |
---|---|
boolean |
add(T obj)
Attempt to aquire a permit to add the object to the pool. |
boolean |
add(T obj,
long offset)
Attempt to aquire a permit to add the object to the pool. |
boolean |
close(long timeout,
java.util.concurrent.TimeUnit unit)
|
void |
discard()
Used when a call to pop() was made that returned null indicating that the caller has a permit to create an object for this pool, but the caller will not be exercising that permit and wishes intstead to return "null" to the pool. |
void |
discard(Pool.Entry entry)
|
void |
flush()
|
Pool.Entry |
pop(long timeout,
java.util.concurrent.TimeUnit unit)
Any successful pop() call requires a corresponding push() or discard() call A pop() call that returns null is considered successful. |
boolean |
push(Pool.Entry entry)
|
boolean |
push(T obj)
Never call this method without having successfully called pop(long, java.util.concurrent.TimeUnit) beforehand. |
boolean |
running()
|
Pool |
start()
|
void |
stop()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Pool(int max, int min, boolean strict)
public Pool(int max, int min, boolean strict, long maxAge, long idleTimeout, long sweepInterval, java.util.concurrent.Executor executor, Pool.Supplier<T> supplier, boolean replaceAged, double maxAgeOffset, boolean garbageCollection, boolean replaceFlushed)
Method Detail |
---|
public Pool start()
public void stop()
public boolean running()
public void flush()
public Pool.Entry pop(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
timeout
- time to block while waiting for an instanceunit
- unit of time dicated by the timeout
java.lang.InterruptedException
- vm level thread interruption
java.lang.IllegalStateException
- if a permit could not be acquired
java.util.concurrent.TimeoutException
- if no instance could be obtained within the timeoutpublic boolean add(T obj)
obj
- object to add to the pool
public boolean add(T obj, long offset)
obj
- object to add to the pooloffset
- creation time offset, used for maxAge
public boolean push(T obj)
pop(long, java.util.concurrent.TimeUnit)
beforehand.
Failure to do so will increase the max pool size by one.
obj
- object to push onto the pool
public boolean push(Pool.Entry entry)
public void discard()
public void discard(Pool.Entry entry)
public boolean close(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
java.lang.InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |