Package com.tangosol.util
Class MultiBinaryLongMap.PrimaryBinaryLongMap.ValidatingLock
- java.lang.Object
-
- com.tangosol.util.MultiBinaryLongMap.PrimaryBinaryLongMap.ValidatingLock
-
- All Implemented Interfaces:
Lock
- Enclosing class:
- MultiBinaryLongMap.PrimaryBinaryLongMap
protected class MultiBinaryLongMap.PrimaryBinaryLongMap.ValidatingLock extends Object implements Lock
ValidatingLock is a Lock implementation specialized for the PrimaryBinaryLongMap that validates after every lock acquisition that the underlying BinaryLongMap implementation did not change.Note: ValidatingLock is assumed to be used by the PrimaryBinaryLongMap to wrap lock implementations that are dependent (chained) to the "master" RW-lock. As the master RW-lock is used to protect any structural changes, it also implicitly serves as a JMM memory barrier that guarantees a "flush" of the map implementation reference.
-
-
Field Summary
Fields Modifier and Type Field Description protected Lock
f_lock
The underlying lock.protected BinaryLongMap
m_blmImpl
The primary BinaryLongMap implementation to check for
-
Constructor Summary
Constructors Constructor Description ValidatingLock(BinaryLongMap blm, Lock lock)
Construct a ValidatingLock backed by the specified Lock.ValidatingLock(Lock lock)
Construct a ValidatingLock backed by the specified Lock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BinaryLongMap
getImplMap()
Return the primary BinaryLongMap implementation validate by this ValidatingLock.void
lock()
void
lockInterruptibly()
Condition
newCondition()
protected void
setImplMap(BinaryLongMap blmImpl)
Set the primary BinaryLongMap implementation to be validated by this ValidatingLock.boolean
tryLock()
boolean
tryLock(long cTime, TimeUnit unit)
void
unlock()
protected void
validate()
Validate that the BinaryLongMap associated with this ValidatingLock is still the implementation map of the containing PrimaryBinaryLongMap.
-
-
-
Field Detail
-
f_lock
protected final Lock f_lock
The underlying lock.
-
m_blmImpl
protected BinaryLongMap m_blmImpl
The primary BinaryLongMap implementation to check for
-
-
Constructor Detail
-
ValidatingLock
public ValidatingLock(Lock lock)
Construct a ValidatingLock backed by the specified Lock.- Parameters:
lock
- the underlying lock
-
ValidatingLock
public ValidatingLock(BinaryLongMap blm, Lock lock)
Construct a ValidatingLock backed by the specified Lock.- Parameters:
blm
- the primary BinaryLongMap implementation to validatelock
- the underlying lock
-
-
Method Detail
-
lockInterruptibly
public void lockInterruptibly() throws InterruptedException
- Specified by:
lockInterruptibly
in interfaceLock
- Throws:
InterruptedException
-
tryLock
public boolean tryLock(long cTime, TimeUnit unit) throws InterruptedException
- Specified by:
tryLock
in interfaceLock
- Throws:
InterruptedException
-
newCondition
public Condition newCondition()
- Specified by:
newCondition
in interfaceLock
-
getImplMap
protected BinaryLongMap getImplMap()
Return the primary BinaryLongMap implementation validate by this ValidatingLock.- Returns:
- the primary BinaryLongMap implementation validated by this ValidatingLock
-
setImplMap
protected void setImplMap(BinaryLongMap blmImpl)
Set the primary BinaryLongMap implementation to be validated by this ValidatingLock.- Parameters:
blmImpl
- the primary BinaryLongMap implementation
-
validate
protected void validate()
Validate that the BinaryLongMap associated with this ValidatingLock is still the implementation map of the containing PrimaryBinaryLongMap.Callers are required to hold the lock. Note: the lock provides a memory barrier ensuring visibility of updates to the map implementation of the outer PrimaryBinaryLongMap.
-
-