ccs.beetree
Class DualModeLock

java.lang.Object
  extended by ccs.beetree.DualModeLock

public class DualModeLock
extends java.lang.Object

A nestable, MT-safe lock which provides inclusive ("read") or exclusive ("write") locking. This is primarily BeeTree internals; however, it is made public in case other apps find it useful.


Constructor Summary
DualModeLock()
           
 
Method Summary
static long getTimeout()
           
 void lockRO()
          Lock for read-only operations.
 void lockRW()
          Lock for read-write operations.
static void setTimeout(long millis)
          Set a deadlock timeout.
 void unlockRO()
          Release an RO lock.
 void unlockRW()
          Release an RO lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DualModeLock

public DualModeLock()
Method Detail

lockRO

public void lockRO()
            throws DeadlockException
Lock for read-only operations. Many readers may share the lock. It is OK to acquire an RO lock even if you already have an RW lock.

Throws:
DeadlockException

lockRW

public void lockRW()
            throws DeadlockException
Lock for read-write operations. This lock is exclusive. Attempting to gain the RW lock while holding the RO lock WILL DEADLOCK.

Throws:
DeadlockException

unlockRO

public void unlockRO()
Release an RO lock. You must unlock as many times as you have previously locked. NB. there used to be a communal unlock method for both RO and RW locks; no longer. You must unlock exactly as you locked.


unlockRW

public void unlockRW()
Release an RO lock. You must unlock as many times as you have previously locked. NB. there used to be a communal unlock method for both RO and RW locks; no longer. You must unlock exactly as you locked.


setTimeout

public static void setTimeout(long millis)
Set a deadlock timeout. If >0, this is the number of millis to wait for a lock; if the lock is not available within this time the attempt will throw.


getTimeout

public static long getTimeout()