org.terracotta.collections
Class FinegrainedLockDso

java.lang.Object
  extended by org.terracotta.collections.FinegrainedLockDso
All Implemented Interfaces:
Comparable<FinegrainedLockDso>, FinegrainedLock

public class FinegrainedLockDso
extends Object
implements FinegrainedLock, Comparable<FinegrainedLockDso>


Method Summary
 int compareTo(FinegrainedLockDso o)
           
 boolean isHeldByCurrentThread()
          Indicates whether the current thread is holding a lock that corresponds to this granularity and default lock type.
 boolean isHeldByCurrentThread(LockType lockType)
          Indicates whether the current thread is holding a lock that corresponds to this granularity and specified lock type.
 void lock()
          Lock the underlying data structure for this lock's granularity using the default lock type.
 void lock(LockType lockType)
          Lock the underlying data structure for this lock's granularity with a specified lock type.
 boolean tryLock()
          Lock the underlying data structure for this lock's granularity using the default lock type only if the lock is not held by another thread at the time of invocation.
 boolean tryLock(LockType lockType)
          Lock the underlying data structure for this lock's granularity with a specified lock type only if the lock is not held by another thread at the time of invocation.
 boolean tryLock(LockType lockType, long timeout, TimeUnit unit)
          Lock the underlying data structure for this lock's granularity with a specified lock type only if the lock is not held by another thread within a given time.
 boolean tryLock(long timeout, TimeUnit unit)
          Lock the underlying data structure for this lock's granularity using the default lock type only if the lock is not held by another thread within a given time.
 void unlock()
          Unlocks the underlying data structure for this lock's granularity using the default lock type.
 void unlock(LockType lockType)
          Unlocks the underlying data structure for this lock's granularity using the specified lock type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

lock

public void lock()
Description copied from interface: FinegrainedLock
Lock the underlying data structure for this lock's granularity using the default lock type.

Specified by:
lock in interface FinegrainedLock

lock

public void lock(LockType lockType)
Description copied from interface: FinegrainedLock
Lock the underlying data structure for this lock's granularity with a specified lock type.

Specified by:
lock in interface FinegrainedLock
Parameters:
lockType - the type of lock that needs to be locked

tryLock

public boolean tryLock()
Description copied from interface: FinegrainedLock
Lock the underlying data structure for this lock's granularity using the default lock type only if the lock is not held by another thread at the time of invocation.

Specified by:
tryLock in interface FinegrainedLock
Returns:
true if the lock was successfully acquired; or {@code false) otherwise

tryLock

public boolean tryLock(LockType lockType)
Description copied from interface: FinegrainedLock
Lock the underlying data structure for this lock's granularity with a specified lock type only if the lock is not held by another thread at the time of invocation.

Specified by:
tryLock in interface FinegrainedLock
Parameters:
lockType - the type of lock that needs to be locked
Returns:
true if the lock was successfully acquired; or {@code false) otherwise

tryLock

public boolean tryLock(long timeout,
                       TimeUnit unit)
                throws InterruptedException
Description copied from interface: FinegrainedLock
Lock the underlying data structure for this lock's granularity using the default lock type only if the lock is not held by another thread within a given time.

Specified by:
tryLock in interface FinegrainedLock
Parameters:
timeout - the time to wait
unit - the time unit of the timeout argument
Returns:
true if the lock was successfully acquired; or {@code false) otherwise
Throws:
InterruptedException

tryLock

public boolean tryLock(LockType lockType,
                       long timeout,
                       TimeUnit unit)
                throws InterruptedException
Description copied from interface: FinegrainedLock
Lock the underlying data structure for this lock's granularity with a specified lock type only if the lock is not held by another thread within a given time.

Specified by:
tryLock in interface FinegrainedLock
Parameters:
lockType - the type of lock that needs to be locked
timeout - the time to wait
unit - the time unit of the timeout argument
Returns:
true if the lock was successfully acquired; or {@code false) otherwise
Throws:
InterruptedException

unlock

public void unlock()
Description copied from interface: FinegrainedLock
Unlocks the underlying data structure for this lock's granularity using the default lock type.

Specified by:
unlock in interface FinegrainedLock

unlock

public void unlock(LockType lockType)
Description copied from interface: FinegrainedLock
Unlocks the underlying data structure for this lock's granularity using the specified lock type.

Specified by:
unlock in interface FinegrainedLock
Parameters:
lockType - the type of lock that needs to be unlocked

isHeldByCurrentThread

public boolean isHeldByCurrentThread()
Description copied from interface: FinegrainedLock
Indicates whether the current thread is holding a lock that corresponds to this granularity and default lock type.

Specified by:
isHeldByCurrentThread in interface FinegrainedLock
Returns:
true if the current thread is holding the lock; or false otherwise

isHeldByCurrentThread

public boolean isHeldByCurrentThread(LockType lockType)
Description copied from interface: FinegrainedLock
Indicates whether the current thread is holding a lock that corresponds to this granularity and specified lock type.

Specified by:
isHeldByCurrentThread in interface FinegrainedLock
Parameters:
lockType - the type of lock that needs to be checked
Returns:
true if the current thread is holding the lock; or false otherwise

compareTo

public int compareTo(FinegrainedLockDso o)
Specified by:
compareTo in interface Comparable<FinegrainedLockDso>


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