org.d_haven.mpool

Class FixedSizePool

public final class FixedSizePool extends AbstractPool

This is an Pool that caches Poolable objects for reuse. Please note that this pool offers no resource limiting whatsoever.

Version: CVS $Revision: 1.11 $ $Date: 2004/06/21 17:03:46 $

Author: Berin Loritsch

Field Summary
Listm_buffer
booleanm_disposed
longm_stepTime
longm_timeout
Constructor Summary
FixedSizePool(ObjectFactory factory, int size)
Create a fixed size pool using the object factory and size supplied.
FixedSizePool(ObjectFactory factory, int size, long timeout)
Create a fixed size pool using the object factory, size, and timeout supplied.
Method Summary
voiddispose()
Dispose this pool and remove all elements.
protected ObjectdoAcquire()
protected booleandoRelease(Object object)
longgetTimeout()
Get the timeout in milliseconds for this pool.
ObjectpopLast()
StringtoString()

Field Detail

m_buffer

private final List m_buffer

m_disposed

private boolean m_disposed

m_stepTime

private final long m_stepTime

m_timeout

private final long m_timeout

Constructor Detail

FixedSizePool

public FixedSizePool(ObjectFactory factory, int size)
Create a fixed size pool using the object factory and size supplied. The pool will use the defuault timeout of -1 (don't block at all) so it will fail early.

Parameters: factory the factory to use for the pool size the number of items in the pool (hard limit)

Throws: Exception if there is a problem creating any of the items in the pool

FixedSizePool

public FixedSizePool(ObjectFactory factory, int size, long timeout)
Create a fixed size pool using the object factory, size, and timeout supplied. A timeout of -1 will not block at all. A timeout of 0 will block indefinitely. A timeout of 1 or more will block for that number of milliseconds.

Parameters: factory the factory to use for the pool size the number of items in the pool (hard limit) timeout the timeout in milliseconds to use.

Throws: Exception if there is a problem creating any of the items in the pool

Method Detail

dispose

public void dispose()
Dispose this pool and remove all elements.

doAcquire

protected Object doAcquire()

doRelease

protected boolean doRelease(Object object)

getTimeout

public long getTimeout()
Get the timeout in milliseconds for this pool.

Returns: the timeout in milliseconds

popLast

private Object popLast()

toString

public String toString()