public class ReferenceCountingAllocator<T extends Recyclable> extends java.lang.Object implements Allocator<T>
Allocator that uses reference counting to determine when an object
should
be recycled and placed back into the pool to be reused.| Constructor and Description |
|---|
ReferenceCountingAllocator(int initialSize,
Supplier<T> factory) |
ReferenceCountingAllocator(Supplier<T> factory) |
| Modifier and Type | Method and Description |
|---|---|
Reference<T> |
allocate()
Allocate an object from the internal pool.
|
java.util.List<Reference<T>> |
allocateBatch(int size)
Allocate a batch of objects all at once.
|
void |
release(java.util.List<Reference<T>> batch)
Efficiently release a batch of References all at once.
|
public Reference<T> allocate()
Allocatorallocate in interface Allocator<T extends Recyclable>Reference that can be retained and released.public java.util.List<Reference<T>> allocateBatch(int size)
AllocatorallocateBatch in interface Allocator<T extends Recyclable>size - the number of objects to allocateList of References to the allocated objects