|
J avolution v5.4 (J2SE 1.6+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavolution.context.Allocator<T>
public abstract class Allocator<T>
This class represents an object allocator; instances of this class
are generated by AllocatorContext
.
If an allocator has recycled objects available, those are returned first, before allocating new ones.
Allocator instances are thread-safe without synchronization,
they are the "production lines" of the factories
,
their implementation is derived from the AllocatorContext
to which they belong (e.g. heap allocators for HeapContext
).
AllocatorContext.getAllocator(ObjectFactory)
Field Summary | |
---|---|
protected T[] |
queue
Holds the queue of objects belonging to this allocator (always used first when available). |
protected int |
queueSize
Holds the number of objects in this allocator queue. |
protected java.lang.Thread |
user
Holds the current user or null if deactivated. |
Constructor Summary | |
---|---|
protected |
Allocator()
Default constructor. |
Method Summary | |
---|---|
protected abstract T |
allocate()
Allocates a new object, this method is called when the allocator queue is empty. |
T |
next()
Returns the next available object from this allocator queue or allocate() one if none available. |
protected abstract void |
recycle(T object)
Recycles the specified object to this queue. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Thread user
null
if deactivated.
protected T[] queue
protected int queueSize
Constructor Detail |
---|
protected Allocator()
Method Detail |
---|
public final T next()
allocate()
one if none available.
protected abstract T allocate()
protected abstract void recycle(T object)
object
- the object to recycle.
|
J avolution v5.4 (J2SE 1.6+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |