public class BatchFactorySupplier<T> extends java.lang.Object implements Supplier<T>
Supplier implementation that fills a fixed-size array with
pre-allocated objects, which are handed out, one after the other, until the array is exhausted.
At that point, the array is re-filled by creating more objects from the supplied factory and
those objects are then handed out one at a time. There is no limit to the number of items
created by the pool because references to the created objects are not maintained once it
has been retrieved from the pool.| Constructor and Description |
|---|
BatchFactorySupplier(int size,
Supplier<T> factory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
fill() |
T |
get()
Get an object.
|
int |
remaining()
How many unallocated items remain in the pool.
|
int |
size()
Returns the number of items being pooled.
|
public int size()
public int remaining()
protected void fill()