com.tc.object.locks
Interface TerracottaLocking

All Known Subinterfaces:
Manager
All Known Implementing Classes:
NullManager

public interface TerracottaLocking


Method Summary
 LockID generateLockIdentifier(java.lang.Object obj)
           
 LockID generateLockIdentifier(java.lang.Object obj, java.lang.String field)
           
 LockID generateLockIdentifier(java.lang.String str)
           
 int globalHoldCount(LockID lock, LockLevel level)
          Return the count of global (cluster-wide) holders at the given lock level.
 int globalPendingCount(LockID lock)
          Return the count of global (cluster-wide) pending holders.
 int globalWaitingCount(LockID lock)
          Return the count of global (cluster-wide) waiting threads.
 boolean isLocked(LockID lock, LockLevel level)
          Return true if the given lock is held by any thread at the given lock level.
 boolean isLockedByCurrentThread(LockID lock, LockLevel level)
          Return true if the given lock is held by the current thread at the given lock level.
 boolean isLockedByCurrentThread(LockLevel level)
          Return true if any lock is held by the current thread at the given lock level.
 int localHoldCount(LockID lock, LockLevel level)
          Return the count of local (on this client VM) holders at the given lock level.
 void lock(LockID lock, LockLevel level)
          Blocking acquire of a Terracotta lock.
 void lockInterruptibly(LockID lock, LockLevel level)
          Interruptible acquire of a Terracotta lock.
 Notify notify(LockID lock, java.lang.Object waitObject)
          Notify a single thread waiting on the given lock.
 Notify notifyAll(LockID lock, java.lang.Object waitObject)
          Notify all threads waiting on the given lock.
 void pinLock(LockID lock)
           
 boolean tryLock(LockID lock, LockLevel level)
          Try to acquire a Terracotta lock.
 boolean tryLock(LockID lock, LockLevel level, long timeout)
          Timed acquire of a Terracotta lock.
 void unlock(LockID lock, LockLevel level)
          Blocking unlock of a Terracotta lock.
 void unpinLock(LockID lock)
           
 void wait(LockID lock, java.lang.Object waitObject)
          Move the current thread to wait on the given lock.
 void wait(LockID lock, java.lang.Object waitObject, long timeout)
          Move the current thread to wait on the given lock with timeout.
 

Method Detail

lock

void lock(LockID lock,
          LockLevel level)
Blocking acquire of a Terracotta lock.

Parameters:
lock - lock to act upon
level - level at which to lock
Throws:
TCLockUpgradeNotSupportedError - on attempting to read→write upgrade

tryLock

boolean tryLock(LockID lock,
                LockLevel level)
Try to acquire a Terracotta lock.

Non-blocking try acquires will wait for a definitive server response - in this sense they are not truly non-blocking...

Parameters:
lock - lock to act upon
level - level at which to lock
Returns:
true if locked
Throws:
TCLockUpgradeNotSupportedError - on attempting to read→write upgrade

tryLock

boolean tryLock(LockID lock,
                LockLevel level,
                long timeout)
                throws java.lang.InterruptedException
Timed acquire of a Terracotta lock.

Parameters:
lock - lock to act upon
level - level at which to lock
timeout - maximum time to wait in milliseconds
Returns:
true if locked
Throws:
TCLockUpgradeNotSupportedError - on attempting to read→write upgrade
java.lang.InterruptedException

lockInterruptibly

void lockInterruptibly(LockID lock,
                       LockLevel level)
                       throws java.lang.InterruptedException
Interruptible acquire of a Terracotta lock.

Parameters:
lock - lock to act upon
level - level at which to lock
Throws:
TCLockUpgradeNotSupportedError - on attempting to read→write upgrade
java.lang.InterruptedException

unlock

void unlock(LockID lock,
            LockLevel level)
Blocking unlock of a Terracotta lock.

Parameters:
lock - lock to act upon
level - at which to unlock
Throws:
java.lang.IllegalMonitorStateException - if there is no matching lock hold

notify

Notify notify(LockID lock,
              java.lang.Object waitObject)
Notify a single thread waiting on the given lock.

Parameters:
lock - lock to act upon
waitObject - local vm object on which threads are waiting
Throws:
java.lang.IllegalMonitorStateException - if the current thread does not hold a write lock

notifyAll

Notify notifyAll(LockID lock,
                 java.lang.Object waitObject)
Notify all threads waiting on the given lock.

Parameters:
lock - lock to act upon
waitObject - local vm object on which threads are waiting
Throws:
java.lang.IllegalMonitorStateException - if the current thread does not hold a write lock

wait

void wait(LockID lock,
          java.lang.Object waitObject)
          throws java.lang.InterruptedException
Move the current thread to wait on the given lock.

Parameters:
lock - lock to act upon
waitObject - local vm object to wait on
Throws:
java.lang.IllegalMonitorStateException - if the current thread does not hold a write lock
java.lang.InterruptedException

wait

void wait(LockID lock,
          java.lang.Object waitObject,
          long timeout)
          throws java.lang.InterruptedException
Move the current thread to wait on the given lock with timeout.

Parameters:
lock - lock to act upon
waitObject - local vm object to wait on
timeout - maximum time to remain waiting
Throws:
java.lang.IllegalMonitorStateException - if the current thread does not hold a write lock
java.lang.InterruptedException

isLocked

boolean isLocked(LockID lock,
                 LockLevel level)
Return true if the given lock is held by any thread at the given lock level.

The semantics of this method are fairly loose when using a greedy locking policy. It is assumed that a client holding a greedy lock has in turn one holding thread of each possible type.

It is also important to note that the current locking implementation does not track concurrent lock holds.

Parameters:
lock - lock to query
level - level to query

isLockedByCurrentThread

boolean isLockedByCurrentThread(LockID lock,
                                LockLevel level)
Return true if the given lock is held by the current thread at the given lock level.

It is also important to note that the current locking implementation does not track concurrent lock holds.

Parameters:
lock - lock to query
level - level to query

isLockedByCurrentThread

boolean isLockedByCurrentThread(LockLevel level)
Return true if any lock is held by the current thread at the given lock level.

It is also important to note that the current locking implementation does not track concurrent lock holds.

Parameters:
level - level to query

localHoldCount

int localHoldCount(LockID lock,
                   LockLevel level)
Return the count of local (on this client VM) holders at the given lock level.

Parameters:
lock - lock to query
level - level to query

globalHoldCount

int globalHoldCount(LockID lock,
                    LockLevel level)
Return the count of global (cluster-wide) holders at the given lock level.

This method has unusual semantics similar to isLocked.

Parameters:
lock - lock to query
level - level to query
See Also:
isLocked(LockID, LockLevel)

globalPendingCount

int globalPendingCount(LockID lock)
Return the count of global (cluster-wide) pending holders.

This method has unusual semantics similar to isLocked.

Parameters:
lock - lock to query
See Also:
isLocked(LockID, LockLevel)

globalWaitingCount

int globalWaitingCount(LockID lock)
Return the count of global (cluster-wide) waiting threads.

This method has unusual semantics similar to isLocked.

Parameters:
lock - lock to query
See Also:
isLocked(LockID, LockLevel)

pinLock

void pinLock(LockID lock)

unpinLock

void unpinLock(LockID lock)

generateLockIdentifier

LockID generateLockIdentifier(java.lang.String str)

generateLockIdentifier

LockID generateLockIdentifier(java.lang.Object obj)

generateLockIdentifier

LockID generateLockIdentifier(java.lang.Object obj,
                              java.lang.String field)


Copyright © 2010 Terracotta, Inc.. All Rights Reserved.