|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.cache.SynchronizedHardReferenceQueue<T>
public class SynchronizedHardReferenceQueue<T>
Thread-safe version.
| Field Summary | |
|---|---|
protected HardReferenceQueue<T> |
queue
Note: Synchronization for the inner queue is realized using the
outer reference! |
| Fields inherited from interface com.bigdata.cache.IHardReferenceQueue |
|---|
DEFAULT_NSCAN |
| Constructor Summary | |
|---|---|
SynchronizedHardReferenceQueue(HardReferenceQueueEvictionListener<T> listener,
int capacity)
Defaults the #of references to scan on append requests to 10. |
|
SynchronizedHardReferenceQueue(HardReferenceQueueEvictionListener<T> listener,
int capacity,
int nscan)
Core impl. |
|
| Method Summary | |
|---|---|
boolean |
add(T ref)
Add a reference to the cache. |
protected void |
beforeOffer(T t)
All attempts to add an element to the buffer invoke this hook before checking the remaining capacity in the buffer. |
int |
capacity()
The cache capacity. |
void |
clear(boolean clearRefs)
Clears the cache (sets the head, tail and count to zero) without generating eviction notices. |
boolean |
evict()
Evict the LRU reference. |
void |
evictAll(boolean clearRefs)
Evict all references, starting with the LRU reference and proceeding to the MRU reference. |
HardReferenceQueueEvictionListener<T> |
getListener()
|
boolean |
isEmpty()
True iff the cache is empty. |
boolean |
isFull()
True iff the cache is full. |
int |
nscan()
The #of references that are tested on append requests. |
T |
peek()
The reference at the tail of the queue. |
boolean |
scanHead(int nscan,
T ref)
|
boolean |
scanTail(int nscan,
T ref)
|
int |
size()
The #of references in the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final HardReferenceQueue<T> queue
queue is realized using the
outer reference!
| Constructor Detail |
|---|
public SynchronizedHardReferenceQueue(HardReferenceQueueEvictionListener<T> listener,
int capacity)
listener - The listener on which cache evictions are reported.capacity - The maximum #of references that can be stored on the cache.
There is no guarantee that all stored references are distinct.
public SynchronizedHardReferenceQueue(HardReferenceQueueEvictionListener<T> listener,
int capacity,
int nscan)
listener - The listener on which cache evictions are reported (optional).capacity - The maximum #of references that can be stored on the cache.
There is no guarantee that all stored references are distinct.nscan - The #of references to scan from the MRU position before
appended a reference to the cache. Scanning is used to reduce
the chance that references that are touched several times in
near succession from entering the cache more than once. The
#of reference tests trades off against the latency of adding a
reference to the cache.| Method Detail |
|---|
protected void beforeOffer(T t)
public final int capacity()
IHardReferenceQueue
capacity in interface IHardReferenceQueue<T>public HardReferenceQueueEvictionListener<T> getListener()
public int nscan()
IHardReferenceQueue
nscan in interface IHardReferenceQueue<T>public boolean add(T ref)
IHardReferenceQueue
add in interface IHardReferenceQueue<T>ref - The reference to be added.
public void clear(boolean clearRefs)
IHardReferenceQueue
clear in interface IHardReferenceQueue<T>clearRefs - When true the references are explicitly set to
null which can facilitate garbage collection.public boolean evict()
IHardReferenceQueue
evict in interface IHardReferenceQueue<T>HardReferenceQueueEvictionListenerpublic void evictAll(boolean clearRefs)
IHardReferenceQueue
evictAll in interface IHardReferenceQueue<T>clearRefs - When true, the reference are actually cleared from the cache.
This may be false to force persistence of the references in
the cache without actually clearing the cache.public T peek()
IHardReferenceQueue
peek in interface IHardReferenceQueue<T>public boolean isEmpty()
IHardReferenceQueue
isEmpty in interface IHardReferenceQueue<T>public boolean isFull()
IHardReferenceQueue
isFull in interface IHardReferenceQueue<T>
public boolean scanHead(int nscan,
T ref)
public boolean scanTail(int nscan,
T ref)
public int size()
IHardReferenceQueue
size in interface IHardReferenceQueue<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||