com.caucho.db.lock
Class DatabaseLock

java.lang.Object
  extended by com.caucho.db.lock.DatabaseLock
All Implemented Interfaces:
java.util.concurrent.locks.ReadWriteLock

public final class DatabaseLock
extends java.lang.Object
implements java.util.concurrent.locks.ReadWriteLock

Locking for tables/etc.


Constructor Summary
DatabaseLock(java.lang.String id)
           
 
Method Summary
 void lockRead(long timeout)
          Tries to get a read lock.
 void lockWrite(long timeout)
          Attempts to get an exclusive write lock.
 java.util.concurrent.locks.Lock readLock()
           
 java.lang.String toString()
           
 void unlockRead()
           
 void unlockWrite()
          Unlocks the write
 java.util.concurrent.locks.Lock writeLock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DatabaseLock

public DatabaseLock(java.lang.String id)
Method Detail

readLock

public java.util.concurrent.locks.Lock readLock()
Specified by:
readLock in interface java.util.concurrent.locks.ReadWriteLock

writeLock

public java.util.concurrent.locks.Lock writeLock()
Specified by:
writeLock in interface java.util.concurrent.locks.ReadWriteLock

lockRead

public void lockRead(long timeout)
              throws LockTimeoutException
Tries to get a read lock.

Parameters:
timeout - how long to wait for a timeout
Throws:
LockTimeoutException

lockWrite

public void lockWrite(long timeout)
Attempts to get an exclusive write lock.


unlockRead

public void unlockRead()

unlockWrite

public void unlockWrite()
Unlocks the write


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object