Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 10695 invoked from network); 17 Aug 2007 14:31:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Aug 2007 14:31:35 -0000 Received: (qmail 4828 invoked by uid 500); 17 Aug 2007 14:31:32 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 4509 invoked by uid 500); 17 Aug 2007 14:31:31 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 4500 invoked by uid 99); 17 Aug 2007 14:31:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2007 07:31:31 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2007 14:31:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9AF6A1A981A; Fri, 17 Aug 2007 07:31:10 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r567058 - /commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java Date: Fri, 17 Aug 2007 14:31:10 -0000 To: commits@commons.apache.org From: ozeigermann@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070817143110.9AF6A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;