|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.container.SpinLockBasedFIFODataContainer
@ThreadSafe public class SpinLockBasedFIFODataContainer
A data container that exposes an iterator that is ordered based on order of entry into the container, with the oldest entries first.
This data container that maintains a concurrent hashtable of entries, and also maintains linking between the elements for ordered iterators. This uses concepts fromConcurrentHashMap
in that it maintains a table of lockable
Segments, each of which is a specialized Hashtable, but HashEntries are also linked to each other such that they can
be navigated, like a LinkedHashMap
. To ensure thread safety of links between entries, we follow
auxillary node ideas expressed in John D. Valois' paper, Lock-Free
Linked Lists Using Compare-and-Swap.
The locks maintained on linkable entrues are implemented using SpinLockBasedFIFODataContainer.SpinLock
s,
and due to the nature of these spin locks, they should only be held for a minimal amount of time.
Nested Class Summary | |
---|---|
protected static class |
SpinLockBasedFIFODataContainer.Aux
|
protected class |
SpinLockBasedFIFODataContainer.KeyIterator
|
protected class |
SpinLockBasedFIFODataContainer.KeySet
|
protected static class |
SpinLockBasedFIFODataContainer.LinkedEntry
|
protected class |
SpinLockBasedFIFODataContainer.LinkedIterator
|
protected static class |
SpinLockBasedFIFODataContainer.SpinLock
|
protected class |
SpinLockBasedFIFODataContainer.ValueIterator
|
Constructor Summary | |
---|---|
SpinLockBasedFIFODataContainer()
|
Method Summary | |
---|---|
void |
clear()
Removes all entries in the container |
boolean |
containsKey(Object k)
Tests whether an entry exists in the container |
InternalCacheEntry |
get(Object k)
Retrieves a cached entry |
protected void |
initLinks()
Initializes links to an empty container |
Iterator<InternalCacheEntry> |
iterator()
|
Set<Object> |
keySet()
|
void |
purgeExpired()
Purges entries that have passed their expiry time |
void |
put(Object k,
Object v,
long lifespan,
long maxIdle)
Puts an entry in the cache along with a lifespan and a maxIdle time |
InternalCacheEntry |
remove(Object k)
Removes an entry from the cache |
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpinLockBasedFIFODataContainer()
Method Detail |
---|
public InternalCacheEntry get(Object k)
DataContainer
get
in interface DataContainer
k
- key under which entry is stored
public void put(Object k, Object v, long lifespan, long maxIdle)
DataContainer
put
in interface DataContainer
k
- key under which to store entryv
- value to storelifespan
- lifespan in milliseconds. -1 means immortal.maxIdle
- max idle time for which to store entry. -1 means forever.public boolean containsKey(Object k)
DataContainer
containsKey
in interface DataContainer
k
- key to test
public InternalCacheEntry remove(Object k)
DataContainer
remove
in interface DataContainer
k
- key to remove
public int size()
size
in interface DataContainer
public void clear()
DataContainer
clear
in interface DataContainer
public Set<Object> keySet()
keySet
in interface DataContainer
public void purgeExpired()
DataContainer
purgeExpired
in interface DataContainer
public Iterator<InternalCacheEntry> iterator()
iterator
in interface Iterable<InternalCacheEntry>
protected final void initLinks()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |