Package com.j_spaces.kernel
Class SimpleLockStoredList<T>
java.lang.Object
com.j_spaces.kernel.AbstractStoredList<T>
com.j_spaces.kernel.SimpleLockStoredList<T>
- All Implemented Interfaces:
IHashEntry<Object,,IStoredList<T>> ICollection<T>,IStoredList<T>,IObjectsList,Iterable<T>
- Direct Known Subclasses:
HashedSimpleLockIStoredList
Read/Write Lock version of StoredList to be used with JDK 1.5+
-
Field Summary
FieldsFields inherited from class com.j_spaces.kernel.AbstractStoredList
m_AllOccupiedPos, m_BasicOccupied, m_Head, m_LastChunk, m_LastPos, m_Size, m_Support_Random_Scans, m_Tail, MINIMAL_NUMBER_TO_HANDLE_POSITIONS, NUMBER_OF_OCCUPIED_POS_QUOTA, SCAN_LIMIT -
Constructor Summary
ConstructorsConstructorDescriptionSimpleLockStoredList(boolean Support_Random_Scans) SimpleLockStoredList(boolean Support_Random_Scans, IReusableResourcePool<ReadWriteLock> locksPool) Create new stored list that will use the given ReadWriteLock for synchronization. -
Method Summary
Modifier and TypeMethodDescriptionstore an elementaddUnlocked(T subject) store an element, while the SL is unlockedbooleanis this object contained in the SL ?intgetHashCode(int id) getHead()get head of SLgetKey(int id) get object from head of SLgetValue(int id) booleanSets an indication that this StoredList is invalid.booleanisEmpty()Returns true if this list is empty, i.e.protected booleanbooleanprotected booleaniterate(boolean random_scan, StoredListIterator<T> res) booleannextPos(StoredListIterator<T> slh) booleanreturn true if we can save iterator creation and get a single entryvoidremove(IObjectInfo<T> oi) remove an element described by ObjectInfobooleanremoveByObject(T obj) given an object scan the list, find it and remove it, returns true if foundvoidremoveUnlocked(IObjectInfo<T> oi) remove an element described by ObjectInfo, while the SL is unlockedintsize()Returns the amount of elements in the StoredList.Methods inherited from class com.j_spaces.kernel.AbstractStoredList
contains_impl, dump, establishListScan, establishListScan, freeSLHolder, isIterator, isMultiObjectCollection, iterator, iterator, next, remove_impl, removeByObject_impl, store_impl, storeBeforeCeiling_implMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
lock
-
-
Constructor Details
-
SimpleLockStoredList
public SimpleLockStoredList(boolean Support_Random_Scans) -
SimpleLockStoredList
public SimpleLockStoredList(boolean Support_Random_Scans, IReusableResourcePool<ReadWriteLock> locksPool) Create new stored list that will use the given ReadWriteLock for synchronization. This allows lock reuse between stored lists
-
-
Method Details
-
size
public int size()Description copied from interface:ICollectionReturns the amount of elements in the StoredList.- Returns:
- size of the StoredList
- See Also:
-
optimizeScanForSingleObject
public boolean optimizeScanForSingleObject()return true if we can save iterator creation and get a single entry- Returns:
- true if we can optimize
-
isEmpty
public boolean isEmpty()Description copied from interface:ICollectionReturns true if this list is empty, i.e. has no elements. [Tail] - [Head]- Returns:
trueif list is empty;falseotherwise.
-
getHead
get head of SL- Returns:
- the head of the list
-
getObjectFromHead
get object from head of SL- Returns:
- the value of the head of the list
-
iterate
- Specified by:
iteratein classAbstractStoredList<T>
-
nextPos
- Specified by:
nextPosin classAbstractStoredList<T>
-
add
store an element- Parameters:
subject- element to store.- Returns:
- an information node representing the inserted element;
nullif StoredList has been invalidated.
-
addUnlocked
store an element, while the SL is unlocked- Parameters:
subject- element to store.- Returns:
- an information node representing the inserted element;
nullif StoredList has been invalidated.
-
remove
remove an element described by ObjectInfo- Parameters:
oi- an existing element between Tail and Head
-
removeUnlocked
remove an element described by ObjectInfo, while the SL is unlocked- Parameters:
oi- an existing element between Tail and Head
-
removeByObject
given an object scan the list, find it and remove it, returns true if found- Parameters:
obj- element to remove- Returns:
trueif object was removed;falseotherwise (if element wasn't found)
-
contains
is this object contained in the SL ?- Parameters:
obj- the element to search for- Returns:
trueif element exists in the StoredList;falseotherwise.
-
invalidate
public boolean invalidate()Sets an indication that this StoredList is invalid. if isEmpty() returns true, the indication is set; otherwise the indication remains false. Called by PersistentGC when scanning for empty StoredList that can be garbage collected.- Returns:
trueif StoredList was set to invalid;falseotherwise.
-
isInvalid
protected boolean isInvalid()- Specified by:
isInvalidin classAbstractStoredList<T>- Returns:
- true if the list is invalid
-
getHashCode
public int getHashCode(int id) -
getKey
-
getValue
-
isNativeHashEntry
public boolean isNativeHashEntry()- Returns:
trueif this is a native hashmap entry
-