|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfun.yan.factory.SimplePool<T>
public abstract class SimplePool<T>
A simple implementation of Pool that uses null to indicate non-existent pool entry.
This implementation synchronizes on getMutex()
for thread safety.
| Constructor Summary | |
|---|---|
SimplePool()
|
|
| Method Summary | ||
|---|---|---|
abstract T |
get()
Get the pooled instance. |
|
T |
getInstance(Factory<T> factory)
Apply the pooling strategy and return an instance from either the pool or the factory. |
|
protected abstract java.lang.Object |
getMutex()
Get the object that can be used to synchronize. |
|
T |
getPooledInstance(T def)
Get the instance that's already pooled. |
|
protected static
|
ifnull(X obj,
X def)
|
|
boolean |
isPooled()
Is this pool currently having something in cache? |
|
abstract void |
set(T val)
set an value to the pool. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimplePool()
| Method Detail |
|---|
public T getInstance(Factory<T> factory)
Pool
getInstance in interface Pool<T>factory - the factory to create the object instance.
public T getPooledInstance(T def)
Pool
getPooledInstance in interface Pool<T>def - the default value to return if there's no pooled instance.
public boolean isPooled()
Pool
isPooled in interface Pool<T>
protected static <X> X ifnull(X obj,
X def)
public abstract T get()
public abstract void set(T val)
val - the value to be pooled.protected abstract java.lang.Object getMutex()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||