org.hibernate.cache

Class ReadWriteCache.Lock

Enclosing Class:
ReadWriteCache
Implemented Interfaces:
Serializable, ReadWriteCache.Lockable, SoftLock

public static final class ReadWriteCache.Lock
extends java.lang.Object
implements Serializable, ReadWriteCache.Lockable, SoftLock

A soft lock which supports concurrent locking, timestamped with the time it was released
Author:
Gavin King

Constructor Summary

Lock(long timeout, int id, Object version)

Method Summary

int
getId()
long
getUnlockTimestamp()
boolean
isGettable(long txTimestamp)
locks are not returned to the client!
boolean
isLock()
Yes, this is a lock
boolean
isPuttable(long txTimestamp, Object newVersion, Comparator comparator)
Can the timestamped transaction re-cache this locked item now?
ReadWriteCache.Lock
lock(long timeout, int id)
Increment the lock, setting the new lock timeout
String
toString()
void
unlock(long currentTimestamp)
Decrement the lock, setting the unlock timestamp if now unlocked
boolean
wasLockedConcurrently()
Was this lock held concurrently by multiple transactions?

Constructor Details

Lock

public Lock(long timeout,
            int id,
            Object version)

Method Details

getId

public int getId()

getUnlockTimestamp

public long getUnlockTimestamp()

isGettable

public boolean isGettable(long txTimestamp)
locks are not returned to the client!
Specified by:
isGettable in interface ReadWriteCache.Lockable

isLock

public boolean isLock()
Yes, this is a lock
Specified by:
isLock in interface ReadWriteCache.Lockable

isPuttable

public boolean isPuttable(long txTimestamp,
                          Object newVersion,
                          Comparator comparator)
Can the timestamped transaction re-cache this locked item now?
Specified by:
isPuttable in interface ReadWriteCache.Lockable

lock

public ReadWriteCache.Lock lock(long timeout,
                                int id)
Increment the lock, setting the new lock timeout
Specified by:
lock in interface ReadWriteCache.Lockable

toString

public String toString()

unlock

public void unlock(long currentTimestamp)
Decrement the lock, setting the unlock timestamp if now unlocked
Parameters:
currentTimestamp -

wasLockedConcurrently

public boolean wasLockedConcurrently()
Was this lock held concurrently by multiple transactions?