Author: ozeigermann
Date: Fri Aug 17 07:31:09 2007
New Revision: 567058

URL: http://svn.apache.org/viewvc?view=rev&rev=567058
Log:
Simplified out necessary steps from release

Modified:
    
commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java

Modified: 
commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java
URL: 
http://svn.apache.org/viewvc/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java?view=diff&rev=567058&r1=567057&r2=567058
==============================================================================
--- 
commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java
 (original)
+++ 
commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java
 Fri Aug 17 07:31:09 2007
@@ -201,26 +201,26 @@
             if (current != getExclusiveOwnerThread())
                 return true;
             setExclusiveOwnerThread(null);
-            setState(readerThreads.size());
+            // if we release an exclusive lock, this can only mean we are the
+            // only who possibly could and the only possible outcome is that
+            // afterwards there are no more locks
+            setState(NO_LOCK);
             return true;
         }
 
         protected boolean tryReleaseShared(int unused) {
             Thread current = Thread.currentThread();
+            // if there had been a read lock before, we simply count the state
+            // down by one
             if (readerThreads.remove(current)) {
                 while (true) {
                     int c = getState();
                     int nextc = c - 1;
-                    if (c == WRITE_LOCK) {
-                        return true;
-                    }
-
                     if (!compareAndSetState(c, nextc)) {
                         // oops, someone was faster than us, so try again
                         continue;
                     }
                     return true;
-
                 }
             }
             return true;


Reply via email to