Interface LockTable
- All Known Implementing Classes:
ConcurrentLockSet
interface LockTable
Interface which must be implemented by lock table classes.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWaiters
(Map<Object, Object> waiters) Add all waiters in the lock table to the specified map.boolean
Check whether there are anyone blocked in the lock table.int
Get the wait timeout in milliseconds.lockObject
(CompatibilitySpace compatibilitySpace, Lockable ref, Object qualifier, int timeout) Lock an object.void
Notify the lock table that it has one less waiter.void
Notify the lock table that it has one more waiter.void
setDeadlockTimeout
(int timeout) Set the deadlock timeout.void
setDeadlockTrace
(boolean flag) Enable or disable tracing of deadlocks.void
setWaitTimeout
(int timeout) Set the wait timeout.Create a map containing a snapshot of all the (Lockable
,LockControl
) pairs in the lock table.void
Unlock an object previously locked bylockObject()
.unlockReference
(CompatibilitySpace space, Lockable ref, Object qualifier, Map group) Unlock an object once if it is present in the specified group.boolean
zeroDurationLockObject
(CompatibilitySpace space, Lockable ref, Object qualifier, int timeout) Lock an object and release the lock immediately.
-
Method Details
-
lockObject
Lock lockObject(CompatibilitySpace compatibilitySpace, Lockable ref, 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_WAIT
means don't wait)- Returns:
- a reference to the lock, or
null
if the lock couldn't be obtained immediately and the timeout wasNO_WAIT
orLockOwner
had thenoWait
flag set - Throws:
StandardException
- if the lock could not be obtained
-
unlock
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
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
null
if 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:
true
if someone is blocked,false
otherwise
-
zeroDurationLockObject
boolean zeroDurationLockObject(CompatibilitySpace space, Lockable ref, 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_WAIT
means don't wait)- Returns:
true
if the object was locked, orfalse
if the object couldn't be locked immediately and timeout wasNO_WAIT
orLockOwner
had thenoWait
flag set- Throws:
StandardException
- if the lock could not be obtained
-
shallowClone
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
-true
enables tracing,false
disables tracing
-
addWaiters
Add all waiters in the lock table to the specified map.- Parameters:
waiters
- the map to add the waiters to- See Also:
-