ehcache

net.sf.ehcache.transaction
Interface SoftLock

All Known Implementing Classes:
ReadCommittedSoftLockImpl

public interface SoftLock

A soft lock is used to lock elements in transactional stores

Author:
Ludovic Orban

Method Summary
 void clearTryLock()
          Clear the state of the soft lock after a tryLock() call succeeded.
 void freeze()
          Freeze the soft lock.
 Element getElement(TransactionID currentTransactionId, SoftLockID softLockId)
          Get the element the current transaction is supposed to see.
 Object getKey()
          Get the key of the element this soft lock is guarding
 boolean isExpired()
          Check if the soft lock expired, ie: that the thread which locked it died
 void lock()
          Lock the soft lock
 boolean tryLock(long ms)
          Attempt to lock the soft lock
 void unfreeze()
          Unfreeze the soft lock
 void unlock()
          Unlock the soft lock.
 

Method Detail

getKey

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 executed
softLockId - 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 InterruptedException
Attempt 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:
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 the getElement(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

ehcache

Copyright 2001-2016, Terracotta, Inc.