svn commit: r566828 - in /commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks: ./ ResourceRWLock.java

2007-08-16 Thread ozeigermann
Author: ozeigermann
Date: Thu Aug 16 13:26:46 2007
New Revision: 566828

URL: http://svn.apache.org/viewvc?view=revrev=566828
Log:
Added resource RW lock to suite our special needs

Added:

commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/

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

Added: 
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=autorev=566828
==
--- 
commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java
 (added)
+++ 
commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/locking/locks/ResourceRWLock.java
 Thu Aug 16 13:26:46 2007
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the License); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.transaction.locking.locks;
+
+import java.util.Collection;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Special version of a [EMAIL PROTECTED] ReentrantReadWriteLock}.
+ * 
+ * ul
+ * lieach thread can hold at most one lock level, i.e. either none, read, or
+ * write.
+ * liownership is (also partially) transferable from one thread to another 
(not in this initial implementation)
+ * liupgrade from read-lock to write-lock is supported
+ * liinformation which thread holds which locks is available
+ * /ul
+ */
+public class ResourceRWLock implements ReadWriteLock {
+
+private static final long serialVersionUID = -5452408535686743324L;
+
+private final ResourceRWLock.ReadLock readerLock;
+
+private final ResourceRWLock.WriteLock writerLock;
+
+private final Sync sync = new Sync();
+
+public ResourceRWLock() {
+readerLock = new ReadLock();
+writerLock = new WriteLock();
+}
+
+public ResourceRWLock.WriteLock writeLock() {
+return writerLock;
+}
+
+public ResourceRWLock.ReadLock readLock() {
+return readerLock;
+}
+
+class ReadLock implements Lock {
+public void lock() {
+sync.acquireShared(1);
+}
+
+public void lockInterruptibly() throws InterruptedException {
+sync.acquireSharedInterruptibly(1);
+}
+
+public boolean tryLock() {
+return sync.tryReadLock();
+}
+
+public boolean tryLock(long timeout, TimeUnit unit) throws 
InterruptedException {
+return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
+}
+
+public void unlock() {
+sync.releaseShared(1);
+}
+
+public Condition newCondition() {
+throw new UnsupportedOperationException();
+}
+
+public String toString() {
+StringBuffer buf = new StringBuffer();
+buf.append(super.toString()).append([Read locks = );
+buf.append(]);
+CollectionThread readerThreads = sync.readerThreads;
+for (Thread thread : readerThreads) {
+buf.append(thread.getName());
+buf.append( );
+}
+return buf.toString();
+}
+}
+
+class WriteLock implements Lock {
+public void lock() {
+sync.acquire(1);
+}
+
+public void lockInterruptibly() throws InterruptedException {
+sync.acquireInterruptibly(1);
+}
+
+public boolean tryLock() {
+return sync.tryWriteLock();
+}
+
+public boolean tryLock(long timeout, TimeUnit unit) throws 
InterruptedException {
+return 

svn commit: r566837 - /commons/proper/math/trunk/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java

2007-08-16 Thread luc
Author: luc
Date: Thu Aug 16 13:40:28 2007
New Revision: 566837

URL: http://svn.apache.org/viewvc?view=revrev=566837
Log:
fixed a non-static call to a static method

Modified:

commons/proper/math/trunk/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java

Modified: 
commons/proper/math/trunk/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java?view=diffrev=566837r1=566836r2=566837
==
--- 
commons/proper/math/trunk/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java
 (original)
+++ 
commons/proper/math/trunk/src/test/org/apache/commons/math/transform/FastFourierTransformerTest.java
 Thu Aug 16 13:40:28 2007
@@ -62,7 +62,7 @@
 }
 
 double x2[] = {10.4, 21.6, 40.8, 13.6, 23.2, 32.8, 13.6, 19.2};
-transformer.scaleArray(x2, 1.0 / Math.sqrt(x2.length));
+FastFourierTransformer.scaleArray(x2, 1.0 / Math.sqrt(x2.length));
 Complex y2[] = y;
 
 result = transformer.transform2(y2);




svn commit: r566841 - /commons/proper/math/trunk/src/test/org/apache/commons/math/util/ContinuedFractionTest.java

2007-08-16 Thread luc
Author: luc
Date: Thu Aug 16 13:43:44 2007
New Revision: 566841

URL: http://svn.apache.org/viewvc?view=revrev=566841
Log:
fixed a warning about a missing serialVersionUID

Modified:

commons/proper/math/trunk/src/test/org/apache/commons/math/util/ContinuedFractionTest.java

Modified: 
commons/proper/math/trunk/src/test/org/apache/commons/math/util/ContinuedFractionTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/util/ContinuedFractionTest.java?view=diffrev=566841r1=566840r2=566841
==
--- 
commons/proper/math/trunk/src/test/org/apache/commons/math/util/ContinuedFractionTest.java
 (original)
+++ 
commons/proper/math/trunk/src/test/org/apache/commons/math/util/ContinuedFractionTest.java
 Thu Aug 16 13:43:44 2007
@@ -32,8 +32,10 @@
 super(name);
 }
 
-public void testGoldenRation(){
+public void testGoldenRatio(){
 ContinuedFraction cf = new ContinuedFraction() {
+private static final long serialVersionUID = 4696264881688589546L;
+
 public double getA(int n, double x) {
 return 1.0;
 }