Interface LockTable
-
- All Known Implementing Classes:
ConcurrentLockSet
interface LockTableInterface which must be implemented by lock table classes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddWaiters(java.util.Map<java.lang.Object,java.lang.Object> waiters)Add all waiters in the lock table to the specified map.booleananyoneBlocked()Check whether there are anyone blocked in the lock table.intgetWaitTimeout()Get the wait timeout in milliseconds.LocklockObject(CompatibilitySpace compatibilitySpace, Lockable ref, java.lang.Object qualifier, int timeout)Lock an object.voidoneLessWaiter()Notify the lock table that it has one less waiter.voidoneMoreWaiter()Notify the lock table that it has one more waiter.voidsetDeadlockTimeout(int timeout)Set the deadlock timeout.voidsetDeadlockTrace(boolean flag)Enable or disable tracing of deadlocks.voidsetWaitTimeout(int timeout)Set the wait timeout.java.util.MapshallowClone()Create a map containing a snapshot of all the (Lockable,LockControl) pairs in the lock table.voidunlock(Latch item, int unlockCount)Unlock an object previously locked bylockObject().LockunlockReference(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier, java.util.Map group)Unlock an object once if it is present in the specified group.booleanzeroDurationLockObject(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier, int timeout)Lock an object and release the lock immediately.
-
-
-
Method Detail
-
lockObject
Lock lockObject(CompatibilitySpace compatibilitySpace, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
Lock an object.- Parameters:
compatibilitySpace- the compatibility spaceref- the object to lockqualifier- qualifier of the locktimeout- maximum time to wait in milliseconds (C_LockFactory.NO_WAITmeans don't wait)- Returns:
- a reference to the lock, or
nullif the lock couldn't be obtained immediately and the timeout wasNO_WAITorLockOwnerhad thenoWaitflag set - Throws:
StandardException- if the lock could not be obtained
-
unlock
void unlock(Latch item, int unlockCount)
Unlock an object previously locked bylockObject().- Parameters:
item- the lock to unlockunlockCount- the number of times to unlock the item; or zero, meaning take the unlock count from the item
-
unlockReference
Lock unlockReference(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier, java.util.Map group)
Unlock an object once if it is present in the specified group. Also remove the object from the group.- Parameters:
space- the compatibility spaceref- a reference to the locked objectqualifier- qualifier of the lockgroup- a map representing the locks in a group- Returns:
- the corresponding lock in the group map, or
nullif the object was not unlocked
-
oneMoreWaiter
void oneMoreWaiter()
Notify the lock table that it has one more waiter.
-
oneLessWaiter
void oneLessWaiter()
Notify the lock table that it has one less waiter.
-
anyoneBlocked
boolean anyoneBlocked()
Check whether there are anyone blocked in the lock table.- Returns:
trueif someone is blocked,falseotherwise
-
zeroDurationLockObject
boolean zeroDurationLockObject(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
Lock an object and release the lock immediately. Equivalent toLock lock = lockTable.lockObject(space, ref, qualifier, timeout); lockTable.unlock(lock, 1);
except that the implementation might be more efficient.- Parameters:
space- the compatibility spaceref- a reference to the locked objectqualifier- qualifier of the locktimeout- maximum time to wait in milliseconds (C_LockFactory.NO_WAITmeans don't wait)- Returns:
trueif the object was locked, orfalseif the object couldn't be locked immediately and timeout wasNO_WAITorLockOwnerhad thenoWaitflag set- Throws:
StandardException- if the lock could not be obtained
-
shallowClone
java.util.Map shallowClone()
Create a map containing a snapshot of all the (Lockable,LockControl) pairs in the lock table.- Returns:
- a shallow clone of the lock table
-
setDeadlockTimeout
void setDeadlockTimeout(int timeout)
Set the deadlock timeout.- Parameters:
timeout- deadlock timeout in milliseconds
-
setWaitTimeout
void setWaitTimeout(int timeout)
Set the wait timeout.- Parameters:
timeout- wait timeout in milliseconds
-
getWaitTimeout
int getWaitTimeout()
Get the wait timeout in milliseconds.
-
setDeadlockTrace
void setDeadlockTrace(boolean flag)
Enable or disable tracing of deadlocks.- Parameters:
flag-trueenables tracing,falsedisables tracing
-
addWaiters
void addWaiters(java.util.Map<java.lang.Object,java.lang.Object> waiters)
Add all waiters in the lock table to the specified map.- Parameters:
waiters- the map to add the waiters to- See Also:
LockControl.addWaiters(java.util.Map<java.lang.Object, java.lang.Object>)
-
-