Package com.tangosol.util
Class SegmentedConcurrentMap.LockableEntry
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.SegmentedHashMap.Entry
-
- com.tangosol.util.SegmentedConcurrentMap.LockableEntry
-
- All Implemented Interfaces:
Map.Entry
- Enclosing class:
- SegmentedConcurrentMap
public class SegmentedConcurrentMap.LockableEntry extends SegmentedHashMap.Entry
LockableEntry is an Entry that supports locking. SeeConcurrentMap
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected shortm_cContendThe number of threads that are waiting to lock this Entry.protected shortm_cLockThe lock count (number of times the "lock()" was called by the locking thread).protected Objectm_oLockHolderThe lock holder object.-
Fields inherited from class com.tangosol.util.SegmentedHashMap.Entry
m_eNext, m_nHash, m_oKey, m_oValue
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLockableEntry(Object oKey, Object oValue, int nHash)Construct a LockableEntry for the given entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancasValueInternal(Object oValueAssume, Object oValue)Set the value of this entry to the specified value iff the current value matches the assumed value.ObjectgetLockHolder()Return the holder of this lockable entry, or null if this entry is not locked.SegmentedConcurrentMapgetSource()Return theSegmentedConcurrentMapcontaining thisEntry.booleanisContended()Is there contention (a thread waiting) to lock this Entry?protected booleanisLocked()Is this entry Locked?protected booleanisSynthetic()Is this Entry synthetic?protected voidlock(Object oHolder)Lock this entry for the specified lock holder.protected ObjectsetValueInternal(Object oValue)Replaces the value corresponding to this entry with the specified value (writes through to the map).StringtoString()Render the map entry as a String.protected booleanunlock()Unlock this entry.protected longwaitForNotify(long cWait)Wait for this LockableEntry to be notified that it has been freed by the previous lock-holder.protected longwaitForNotify(long cWait, SegmentedConcurrentMap.ContentionObserver observer)Wait for this LockableEntry to be notified that it has been freed by the previous lock-holder.-
Methods inherited from class com.tangosol.util.SegmentedHashMap.Entry
equals, getKey, getValue, getValueInternal, hashCode, nextEntry, nextEntry, setNext, setValue
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Field Detail
-
m_oLockHolder
protected volatile Object m_oLockHolder
The lock holder object.
-
m_cLock
protected volatile short m_cLock
The lock count (number of times the "lock()" was called by the locking thread).
-
m_cContend
protected volatile short m_cContend
The number of threads that are waiting to lock this Entry.
-
-
Method Detail
-
getLockHolder
public Object getLockHolder()
Return the holder of this lockable entry, or null if this entry is not locked.- Returns:
- the lock holder, or null
-
getSource
public SegmentedConcurrentMap getSource()
Return theSegmentedConcurrentMapcontaining thisEntry.- Returns:
SegmentedConcurrentMapcontaining thisEntry
-
isContended
public boolean isContended()
Is there contention (a thread waiting) to lock this Entry?- Returns:
- true iff another thread is contending for this Entry
-
setValueInternal
protected Object setValueInternal(Object oValue)
Replaces the value corresponding to this entry with the specified value (writes through to the map). The behavior of this call is undefined if the mapping has already been removed from the map.- Overrides:
setValueInternalin classSegmentedHashMap.Entry- Parameters:
oValue- new value to be stored in this entry- Returns:
- old value corresponding to the entry, or NO_VALUE if the Entry was synthetic
-
isSynthetic
protected boolean isSynthetic()
Is this Entry synthetic?- Overrides:
isSyntheticin classSegmentedHashMap.Entry- Returns:
- true iff this Entry is synthetic
-
waitForNotify
protected long waitForNotify(long cWait, SegmentedConcurrentMap.ContentionObserver observer)Wait for this LockableEntry to be notified that it has been freed by the previous lock-holder. If the lock is being held by a thread and that thread has died, release the lock.Ensure the provided
SegmentedConcurrentMap.ContentionObserveris called before and after this thread's wait for the lock-holder to release the lock.- Parameters:
cWait- the number of milliseconds to wait for notification to obtain a lock; pass zero to return immediately; pass -1 to block the calling thread until the lock obtained could beobserver- a ContentionObserver, or null, to be invoked both before and after waiting for the lock-holder to release the lock- Returns:
- updated wait time
-
waitForNotify
protected long waitForNotify(long cWait)
Wait for this LockableEntry to be notified that it has been freed by the previous lock-holder. If the lock is being held by a thread and that thread has died, release the lock.Note: caller of this method is expected to hold a synchronization monitor for this LockableEntry object while making this call.
- Parameters:
cWait- the number of milliseconds to wait for notification to obtain a lock; pass zero to return immediately; pass -1 to block the calling thread until the lock could be obtained- Returns:
- updated wait time
-
lock
protected void lock(Object oHolder)
Lock this entry for the specified lock holder.Note: caller of this method is expected to have locked the segment for this Entry object
- Parameters:
oHolder- the holder of this lock
-
unlock
protected boolean unlock()
Unlock this entry.Note: caller of this method is expected to have locked the segment for this Entry object
- Returns:
- true iff the Entry is completely unlocked
-
casValueInternal
protected boolean casValueInternal(Object oValueAssume, Object oValue)
Set the value of this entry to the specified value iff the current value matches the assumed value.- Parameters:
oValueAssume- the assumed valueoValue- the new value- Returns:
- true iff the value changed
-
toString
public String toString()
Render the map entry as a String.- Overrides:
toStringin classSegmentedHashMap.Entry- Returns:
- the details about this entry
-
isLocked
protected boolean isLocked()
Is this entry Locked?- Returns:
- true iff this entry is locked
-
-