|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gzz.util.BlockPool
A pool for blocks of throw-away objects. A different implementation of pooling, for experimentation. This class makes the pool logic simpler by not making it possible to release a single object at a time.
Therefore, we get rid of the boolean array used and the storage of an integer index per poolable object.
The use of this class requires some more care from the higher-level programmer.
Field Summary | |
static int |
INITIAL_LENGTH
The initial size of the pool array. |
protected int |
nPooled
The number of used entries. |
protected java.lang.Object[] |
pool
The pool of Poolable s. |
static java.lang.String |
rcsid
|
Constructor Summary | |
BlockPool()
|
Method Summary | |
protected abstract java.lang.Object |
create()
Create a new object of the type cached by this Pool . |
java.lang.Object |
getObject()
Get a Placeable object not yet casted to the class
this Pool caches. |
int |
getSize()
Get the current pool size. |
void |
setSize(int size)
Set the current pool size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String rcsid
public static final int INITIAL_LENGTH
null
.
protected java.lang.Object[] pool
Poolable
s.
Valid at least up to n-1
. When looking
beyond endIndex-1
, one must test for null
entries and possibly create new objects through
create()
.
protected int nPooled
Constructor Detail |
public BlockPool()
Method Detail |
protected abstract java.lang.Object create()
Pool
.
This method is called by the getObject()
method
when there is no cached, currently unused instance.
It does not have to worry about putting the object into
the cache
array or about calling setPool
in the Poolable
: the getObject()
method
will take care of that.
public final java.lang.Object getObject()
Placeable
object not yet casted to the class
this Pool
caches. If there is an unused object instance
available, it is returned (and claimed as used); otherwise, a new
instance is created and put into the cache.
public int getSize()
public void setSize(int size)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |