org.terracotta.locking
Class TerracottaReadWriteLock

java.lang.Object
  extended by org.terracotta.locking.TerracottaReadWriteLock
All Implemented Interfaces:
Serializable, ReadWriteLock

public class TerracottaReadWriteLock
extends Object
implements ReadWriteLock, Serializable

A Terracotta clusterable implementation of ReadWriteLock.

Instances can be used in both clustered and unclustered scenarios, but care must be taken to only connect instances to the clustered heap when the lock is in a fully unlocked state to avoid unspecified errors during subsequent unlocking.

Behaviors:

See Also:
Serialized Form

Constructor Summary
TerracottaReadWriteLock()
          Constructs a new TerracottaReadWriteLock with the default write lock behavior.
TerracottaReadWriteLock(boolean synchronousWrite)
          Constructs a new TerracottaReadWriteLock with the defined write lock behavior.
 
Method Summary
 boolean isWriteLockedByCurrentThread()
          Check if the write lock is held by the current thread.
 Lock readLock()
           
 Lock writeLock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerracottaReadWriteLock

public TerracottaReadWriteLock()
Constructs a new TerracottaReadWriteLock with the default write lock behavior.


TerracottaReadWriteLock

public TerracottaReadWriteLock(boolean synchronousWrite)
Constructs a new TerracottaReadWriteLock with the defined write lock behavior.

If synchronous write is set to true then mutations performed within the scope of this locks write lock are synchronously persisted before the unlocking thread returns.

Parameters:
synchronousWrite - true if write locks should be synchronous
Method Detail

readLock

public Lock readLock()
Specified by:
readLock in interface ReadWriteLock

writeLock

public Lock writeLock()
Specified by:
writeLock in interface ReadWriteLock

isWriteLockedByCurrentThread

public boolean isWriteLockedByCurrentThread()
Check if the write lock is held by the current thread.

Returns:
true if the current thread holds the write lock, false otherwise.


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