org.exist.util
Class ReentrantReadWriteLock

java.lang.Object
  extended byorg.exist.util.ReentrantReadWriteLock
All Implemented Interfaces:
Lock

public class ReentrantReadWriteLock
extends java.lang.Object
implements Lock

A lock with the same semantics as builtin Java synchronized locks: Once a thread has a lock, it can re-obtain it any number of times without blocking. The lock is made available to other threads when as many releases as acquires have occurred.

[ Introduction to this package. ]


Field Summary
protected  long holds_
           
protected  java.lang.String id_
           
protected  int mode_
           
protected  java.lang.Thread owner_
           
 
Fields inherited from interface org.exist.util.Lock
READ_LOCK, WRITE_LOCK
 
Constructor Summary
ReentrantReadWriteLock(java.lang.String id)
           
 
Method Summary
 boolean acquire()
           
 boolean acquire(int mode)
           
 long holds()
          Return the number of unreleased acquires performed by the current thread.
 void release()
          Release the lock.
 void release(long n)
          Release the lock N times.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id_

protected java.lang.String id_

owner_

protected java.lang.Thread owner_

holds_

protected long holds_

mode_

protected int mode_
Constructor Detail

ReentrantReadWriteLock

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

acquire

public boolean acquire()
                throws LockException
Specified by:
acquire in interface Lock
Throws:
LockException

acquire

public boolean acquire(int mode)
                throws LockException
Specified by:
acquire in interface Lock
Throws:
LockException

release

public void release()
Release the lock.

Specified by:
release in interface Lock
Throws:
java.lang.Error - thrown if not current owner of lock

release

public void release(long n)
Release the lock N times. release(n) is equivalent in effect to:
   for (int i = 0; i < n; ++i) release();
 

Throws:
java.lang.Error - thrown if not current owner of lock or has fewer than N holds on the lock

holds

public long holds()
Return the number of unreleased acquires performed by the current thread. Returns zero if current thread does not hold lock.



Copyright (C) Wolfgang Meier. All rights reserved.