|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ow2.util.pool.impl.enhanced.impl.basic.BasicPool<E>
E - pool item typepublic class BasicPool<E>
Basic pool implementation. You can dynamically change pool size calling setExpectedSize method.
| Field Summary | |
|---|---|
protected static InfiniteWaitControl |
INFINITE_WAIT_CONTROL
Because basic pool do not delegate, we can use one instance. |
| Constructor Summary | |
|---|---|
BasicPool(IPoolItemFactory<? extends E> poolItemFactory,
int initPoolSize,
IAccessManager<? super E> accessManager,
java.util.concurrent.Executor createItemExecutor,
IPoolItemRemoveListener<? super E> poolItemRemoveCB,
java.util.concurrent.Executor removeItemExecutor)
|
|
| Method Summary | |
|---|---|
protected boolean |
callNextRemoveCallBack()
|
void |
clearPool()
After calling this method the pool will have a zero size and no item will be created until setExpectedSize will be called again. |
protected boolean |
createNewItem()
|
protected void |
createOneItem(E poolItem)
|
E |
get()
This method block is there is no available pool item in the pool. |
E |
get(IWaitControl timeout)
This method block is no instance are available. |
protected java.util.List<E> |
getAvailablePoolItemList()
|
protected int |
getDelayedCount()
|
protected int |
getExpectedSize()
|
protected FactoryState |
getFactoryState()
|
protected java.util.concurrent.locks.Lock |
getLock()
|
protected int |
getOneItem()
|
protected IPoolItemFactory<? extends E> |
getPoolItemFactory()
|
protected IAccessManager<? super E> |
getReleaseListener()
|
protected ISignalClearableCondition |
getSignalClearableCondition()
|
protected long |
getTemporaryBrokenFactoryEndTime()
|
protected java.util.List<E> |
getUnmodifiableAvailablePoolItemList()
|
protected int |
getUnUsedPoolItem()
|
protected int |
getUsedPoolItem()
|
void |
lockSizeToZero()
|
void |
put(E poolItem)
This method will never block. |
protected void |
putOneItem(E poolItem)
|
protected void |
releaseOneItem()
|
protected void |
releasePoolItem(E releasePoolItem)
|
void |
remove(E poolItem)
This method can be called when you finished to use the pool item instead of put method. |
protected void |
removeOneItem(E poolItem)
|
protected void |
setDelayedCount(int delayedCount)
|
void |
setExpectedSize(int expectedSize)
|
protected void |
setUsedPoolItem(int usedPoolItem)
|
void |
signalAllWaiters()
Ask pool to recall all timeout.waitOnXXX. |
void |
unlockSizeToZero()
|
void |
waitAllRemoveListenerCompleted()
After calling this method all pending remove calls will be called. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final InfiniteWaitControl INFINITE_WAIT_CONTROL
| Constructor Detail |
|---|
public BasicPool(IPoolItemFactory<? extends E> poolItemFactory,
int initPoolSize,
IAccessManager<? super E> accessManager,
java.util.concurrent.Executor createItemExecutor,
IPoolItemRemoveListener<? super E> poolItemRemoveCB,
java.util.concurrent.Executor removeItemExecutor)
| Method Detail |
|---|
protected int getOneItem()
protected void createOneItem(E poolItem)
protected void putOneItem(E poolItem)
protected void releaseOneItem()
protected void removeOneItem(E poolItem)
public void setExpectedSize(int expectedSize)
setExpectedSize in interface IResizableexpectedSize - the expectedSize to setpublic void lockSizeToZero()
lockSizeToZero in interface IBasicPool<E>public void unlockSizeToZero()
unlockSizeToZero in interface IBasicPool<E>protected boolean createNewItem()
public E get(IWaitControl timeout)
throws TimeoutPoolException,
IllegalTimeoutException,
WaiterInterruptedException,
java.lang.InterruptedException,
PoolFactoryBroken
get in interface IBasicPool<E>get in interface IPool<E>timeout - after this timeout a exception is thrown
TimeoutPoolException - if timeout
IllegalTimeoutException
WaiterInterruptedException
java.lang.InterruptedException
PoolFactoryBroken
public E get()
throws WaiterInterruptedException,
java.lang.InterruptedException,
PoolFactoryBroken
IBasicPool
get in interface IBasicPool<E>WaiterInterruptedException - if error occurs
java.lang.InterruptedException
PoolFactoryBroken
public void put(E poolItem)
throws NotABusyPoolItemException
put in interface IPool<E>poolItem - a pool item
NotABusyPoolItemException - if error occursprotected IPoolItemFactory<? extends E> getPoolItemFactory()
protected IAccessManager<? super E> getReleaseListener()
protected void setUsedPoolItem(int usedPoolItem)
usedPoolItem - the usedPoolItem to setprotected java.util.List<E> getAvailablePoolItemList()
protected int getExpectedSize()
protected int getUsedPoolItem()
protected int getUnUsedPoolItem()
protected final java.util.concurrent.locks.Lock getLock()
protected ISignalClearableCondition getSignalClearableCondition()
protected int getDelayedCount()
protected void setDelayedCount(int delayedCount)
delayedCount - the delayedCount to setpublic void signalAllWaiters()
IPoolWaitAuthorization
state you can avoid all waiters.
signalAllWaiters in interface IPool<E>protected void releasePoolItem(E releasePoolItem)
public void clearPool()
throws java.lang.InterruptedException
IBasicPool
clearPool in interface IBasicPool<E>java.lang.InterruptedException
public void waitAllRemoveListenerCompleted()
throws java.lang.InterruptedException
IBasicPool
waitAllRemoveListenerCompleted in interface IBasicPool<E>java.lang.InterruptedExceptionprotected boolean callNextRemoveCallBack()
public void remove(E poolItem)
throws NotABusyPoolItemException
IPool
remove in interface IPool<E>poolItem - a pool item
NotABusyPoolItemException - if error occursprotected java.util.List<E> getUnmodifiableAvailablePoolItemList()
protected long getTemporaryBrokenFactoryEndTime()
protected FactoryState getFactoryState()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||