Modifier and Type | Class and Description |
---|---|
static interface |
TryCache.ObjectFactory<T>
Something that creates objects of the type cached by this cache
|
Modifier and Type | Field and Description |
---|---|
protected long |
_lastUnderflow |
protected int |
capacity |
protected List<T> |
items |
protected Lock |
lock |
Constructor and Description |
---|
TryCache(TryCache.ObjectFactory<T> factory,
int capacity) |
protected final int capacity
protected final Lock lock
protected long _lastUnderflow
public TryCache(TryCache.ObjectFactory<T> factory, int capacity)
factory
- to be used for creating new instancescapacity
- cache up to this many itemspublic T acquire()
public void release(T item)
public void clear()