com.bigdata.cache
Interface IHardReferenceQueue<T>

Type Parameters:
T - The generic type of the hard references in the queue.
All Known Implementing Classes:
HardReferenceQueue, HardReferenceQueueWithBatchingUpdates, SynchronizedHardReferenceQueue, SynchronizedHardReferenceQueueWithTimeout

public interface IHardReferenceQueue<T>

Interface for a hard reference queue.

Version:
$Id: IHardReferenceQueue.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
static int DEFAULT_NSCAN
          A reasonable default for the #of references on the head of the queue that should be tested before a reference is appended to the queue.
 
Method Summary
 boolean add(T ref)
          Add a reference to the cache.
 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.
 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.
 int size()
          The #of references in the cache.
 

Field Detail

DEFAULT_NSCAN

static final int DEFAULT_NSCAN
A reasonable default for the #of references on the head of the queue that should be tested before a reference is appended to the queue.

See Also:
Constant Field Values
Method Detail

capacity

int capacity()
The cache capacity.


nscan

int nscan()
The #of references that are tested on append requests.


size

int size()
The #of references in the cache. Note that there is no guarantee that the references are distinct.


isEmpty

boolean isEmpty()
True iff the cache is empty.


isFull

boolean isFull()
True iff the cache is full.


add

boolean add(T ref)
Add a reference to the cache. If the reference was recently added to the cache then this is a NOP. Otherwise the reference is appended to the cache. If a reference is appended to the cache and then cache is at capacity, then the LRU reference is first evicted from the cache.

Parameters:
ref - The reference to be added.
Returns:
True iff the reference was added to the cache and false iff the reference was found in a scan of the nscan MRU cache entries.

evict

boolean evict()
Evict the LRU reference. This is a NOP iff the cache is empty.

Returns:
true iff a reference was evicted.
See Also:
HardReferenceQueueEvictionListener

clear

void clear(boolean clearRefs)
Clears the cache (sets the head, tail and count to zero) without generating eviction notices.

Parameters:
clearRefs - When true the references are explicitly set to null which can facilitate garbage collection.

evictAll

void evictAll(boolean clearRefs)
Evict all references, starting with the LRU reference and proceeding to the MRU reference.

Parameters:
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.

peek

T peek()
The reference at the tail of the queue. This is the next reference that will be evicted from the queue.



Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.