Package net.sf.ehcache.transaction
Interface SoftLock
-
- All Known Implementing Classes:
ReadCommittedSoftLockImpl
public interface SoftLockA soft lock is used to lock elements in transactional stores- Author:
- Ludovic Orban
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearTryLock()Clear the state of the soft lock after a tryLock() call succeeded.voidfreeze()Freeze the soft lock.ElementgetElement(TransactionID currentTransactionId, SoftLockID softLockId)Get the element the current transaction is supposed to see.java.lang.ObjectgetKey()Get the key of the element this soft lock is guardingbooleanisExpired()Check if the soft lock expired, ie: that the thread which locked it diedvoidlock()Lock the soft lockbooleantryLock(long ms)Attempt to lock the soft lockvoidunfreeze()Unfreeze the soft lockvoidunlock()Unlock the soft lock.
-
-
-
Method Detail
-
getKey
java.lang.Object getKey()
Get the key of the element this soft lock is guarding- Returns:
- the key
-
getElement
Element getElement(TransactionID currentTransactionId, SoftLockID softLockId)
Get the element the current transaction is supposed to see.- Parameters:
currentTransactionId- the current transaction under which this call is executedsoftLockId- the soft lock ID- Returns:
- the Element visible to the current transaction
-
lock
void lock()
Lock the soft lock
-
tryLock
boolean tryLock(long ms) throws java.lang.InterruptedExceptionAttempt to lock the soft lock- Parameters:
ms- the time in milliseconds before this method gives up- Returns:
- true if the soft lock was locked, false otherwise
- Throws:
java.lang.InterruptedException- if the thread calling this method was interrupted
-
clearTryLock
void clearTryLock()
Clear the state of the soft lock after a tryLock() call succeeded.
-
unlock
void unlock()
Unlock the soft lock. Once a soft lock got unlocked, it is considered 'dead': it cannot be locked again and must be cleaned up
-
freeze
void freeze()
Freeze the soft lock. A soft lock should only be frozen for a very short period of time as this blocks thegetElement(TransactionID, SoftLockID)method calls. Freeze is used to mark the start of a commit / rollback phase
-
unfreeze
void unfreeze()
Unfreeze the soft lock
-
isExpired
boolean isExpired()
Check if the soft lock expired, ie: that the thread which locked it died- Returns:
- true if the soft lock is orphan and should be cleaned up, false otherwise
-
-