public abstract class Allocator<T>
extends java.lang.Object
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)| Modifier and Type | Field and Description |
|---|---|
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. |
| Modifier | Constructor and Description |
|---|---|
protected |
Allocator()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected java.lang.Thread user
null if deactivated.protected T[] queue
protected int queueSize
public final T next()
allocate() one if none available.protected abstract T allocate()
protected abstract void recycle(T object)
object - the object to recycle.Copyright © 2005 - 2007 Javolution.