You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/07/01 00:37:29 UTC

svn commit: r418401 [16/32] - in /incubator/openjpa/trunk: openjpa-lib/ openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/ openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-lib/src/...

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CopyOnWriteArraySet.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CopyOnWriteArraySet.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CopyOnWriteArraySet.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/CopyOnWriteArraySet.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ *  Licensed 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
+ *  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.
  */
-
 /*
  * Written by Doug Lea with assistance from members of JCP JSR-166
  * Expert Group and released to the public domain. Use, modify, and
@@ -23,59 +19,47 @@
 
 import java.util.*;
 
-
 /**
  * A {@link java.util.Set} that uses an internal {@link CopyOnWriteArrayList}
- * for all of its operations.  Thus, it shares the same basic properties:
+ * for all of its operations. Thus, it shares the same basic properties:
  * <ul>
- *  <li>It is best suited for applications in which set sizes generally
- *       stay small, read-only operations
- *       vastly outnumber mutative operations, and you need
- *       to prevent interference among threads during traversal.
- *  <li>It is thread-safe.
- *  <li>Mutative operations (<tt>add</tt>, <tt>set</tt>, <tt>remove</tt>, etc.)
- *      are expensive since they usually entail copying the entire underlying
- *      array.
- *  <li>Iterators do not support the mutative <tt>remove</tt> operation.
- *  <li>Traversal via iterators is fast and cannot encounter
- *      interference from other threads. Iterators rely on
- *      unchanging snapshots of the array at the time the iterators were
- *      constructed.
+ * <li>It is best suited for applications in which set sizes generally
+ * stay small, read-only operations
+ * vastly outnumber mutative operations, and you need
+ * to prevent interference among threads during traversal.
+ * <li>It is thread-safe.
+ * <li>Mutative operations(<tt>add</tt>, <tt>set</tt>, <tt>remove</tt>, etc.)
+ * are expensive since they usually entail copying the entire underlying array.
+ * <li>Iterators do not support the mutative <tt>remove</tt> operation.
+ * <li>Traversal via iterators is fast and cannot encounter
+ * interference from other threads. Iterators rely on
+ * unchanging snapshots of the array at the time the iterators were constructed.
  * </ul>
- *
- * <p> <b>Sample Usage.</b> The following code sketch uses a
+ *   <b>Sample Usage.</b> The following code sketch uses a
  * copy-on-write set to maintain a set of Handler objects that
  * perform some action upon state updates.
- *
- * <pre>
- * class Handler { void handle(); ... }
- *
- * class X {
- *    private final CopyOnWriteArraySet&lt;Handler&gt; handlers
- *       = new CopyOnWriteArraySet&lt;Handler&gt;();
- *    public void addHandler(Handler h) { handlers.add(h); }
- *
- *    private long internalState;
- *    private synchronized void changeState() { internalState = ...; }
- *
- *    public void update() {
- *       changeState();
- *       for (Handler handler : handlers)
- *          handler.handle();
- *    }
- * }
+ * 
+ * <pre> class Handler { void handle(); ... }
+ *  class X { private final CopyOnWriteArraySet&lt;Handler&gt; handlers
+ * = new CopyOnWriteArraySet&lt;Handler&gt;();
+ * public void addHandler(Handler h) { handlers.add(h); }
+ *  private long internalState;
+ * private synchronized void changeState() { internalState = ...; }
+ *  public void update() { changeState(); for (Handler handler : handlers)
+ * handler.handle(); } }
  * </pre>
- *
- * <p>This class is a member of the
+ *  This class is a member of the
  * <a href="{@docRoot}/../guide/collections/index.html">
  * Java Collections Framework</a>.
- *
+ * 
  * @see CopyOnWriteArrayList
  * @since 1.5
  * @author Doug Lea
  */
-public class CopyOnWriteArraySet extends AbstractSet implements java.io.Serializable {
+public class CopyOnWriteArraySet extends AbstractSet
+    implements java.io.Serializable {
     private static final long serialVersionUID = 5457747651344034263L;
+
     private final CopyOnWriteArrayList al;
 
     /**
@@ -86,9 +70,8 @@
     }
 
     /**
-     * Creates a set containing all of the elements of the specified
-     * collection.
-     *
+     * Creates a set containing all of the elements of the specified collection.
+     * 
      * @param c the collection of elements to initially contain
      * @throws NullPointerException if the specified collection is null
      */
@@ -99,7 +82,7 @@
 
     /**
      * Returns the number of elements in this set.
-     *
+     * 
      * @return the number of elements in this set
      */
     public int size() {
@@ -108,7 +91,7 @@
 
     /**
      * Returns <tt>true</tt> if this set contains no elements.
-     *
+     * 
      * @return <tt>true</tt> if this set contains no elements
      */
     public boolean isEmpty() {
@@ -120,7 +103,7 @@
      * More formally, returns <tt>true</tt> if and only if this set
      * contains an element <tt>e</tt> such that
      * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
-     *
+     * 
      * @param o element whose presence in this set is to be tested
      * @return <tt>true</tt> if this set contains the specified element
      */
@@ -133,15 +116,13 @@
      * If this set makes any guarantees as to what order its elements
      * are returned by its iterator, this method must return the
      * elements in the same order.
-     *
-     * <p>The returned array will be "safe" in that no references to it
-     * are maintained by this set.  (In other words, this method must
+     *  The returned array will be "safe" in that no references to it
+     * are maintained by this set. (In other words, this method must
      * allocate a new array even if this set is backed by an array).
      * The caller is thus free to modify the returned array.
-     *
-     * <p>This method acts as bridge between array-based and collection-based
+     *  This method acts as bridge between array-based and collection-based
      * APIs.
-     *
+     * 
      * @return an array containing all the elements in this set
      */
     public Object[] toArray() {
@@ -154,40 +135,33 @@
      * If the set fits in the specified array, it is returned therein.
      * Otherwise, a new array is allocated with the runtime type of the
      * specified array and the size of this set.
-     *
-     * <p>If this set fits in the specified array with room to spare
+     *  If this set fits in the specified array with room to spare
      * (i.e., the array has more elements than this set), the element in
      * the array immediately following the end of the set is set to
-     * <tt>null</tt>.  (This is useful in determining the length of this
+     * <tt>null</tt>. (This is useful in determining the length of this
      * set <i>only</i> if the caller knows that this set does not contain
      * any null elements.)
-     *
-     * <p>If this set makes any guarantees as to what order its elements
+     *  If this set makes any guarantees as to what order its elements
      * are returned by its iterator, this method must return the elements
      * in the same order.
-     *
-     * <p>Like the {@link #toArray()} method, this method acts as bridge between
-     * array-based and collection-based APIs.  Further, this method allows
+     *  Like the {@link #toArray()} method, this method acts as bridge between
+     * array-based and collection-based APIs. Further, this method allows
      * precise control over the runtime type of the output array, and may,
      * under certain circumstances, be used to save allocation costs.
-     *
-     * <p>Suppose <tt>x</tt> is a set known to contain only strings.
+     *  Suppose <tt>x</tt> is a set known to contain only strings.
      * The following code can be used to dump the set into a newly allocated
      * array of <tt>String</tt>:
-     *
-     * <pre>
-     *     String[] y = x.toArray(new String[0]);</pre>
-     *
-     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
+     * 
+     * <pre> String[] y = x.toArray(new String[0]);</pre>
+     *  Note that <tt>toArray(new Object[0])</tt> is identical in function to
      * <tt>toArray()</tt>.
-     *
+     * 
      * @param a the array into which the elements of this set are to be
-     *        stored, if it is big enough; otherwise, a new array of the same
-     *        runtime type is allocated for this purpose.
+     * stored, if it is big enough; otherwise, a new array of the same
+     * runtime type is allocated for this purpose.
      * @return an array containing all the elements in this set
      * @throws ArrayStoreException if the runtime type of the specified array
-     *         is not a supertype of the runtime type of every element in this
-     *         set
+     * is not a supertype of the runtime type of every element in this set
      * @throws NullPointerException if the specified array is null
      */
     public Object[] toArray(Object[] a) {
@@ -206,11 +180,11 @@
      * Removes the specified element from this set if it is present.
      * More formally, removes an element <tt>e</tt> such that
      * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>,
-     * if this set contains such an element.  Returns <tt>true</tt> if
-     * this set contained the element (or equivalently, if this set
-     * changed as a result of the call).  (This set will not contain the
+     * if this set contains such an element. Returns <tt>true</tt> if
+     * this set contained the element(or equivalently, if this set
+     * changed as a result of the call). (This set will not contain the
      * element once the call returns.)
-     *
+     * 
      * @param o object to be removed from this set, if present
      * @return <tt>true</tt> if this set contained the specified element
      */
@@ -225,10 +199,10 @@
      * <tt>(e==null&nbsp;?&nbsp;e2==null&nbsp;:&nbsp;e.equals(e2))</tt>.
      * If this set already contains the element, the call leaves the set
      * unchanged and returns <tt>false</tt>.
-     *
+     * 
      * @param e element to be added to this set
      * @return <tt>true</tt> if this set did not already contain the specified
-     *         element
+     * element
      */
     public boolean add(Object e) {
         return al.addIfAbsent(e);
@@ -236,12 +210,12 @@
 
     /**
      * Returns <tt>true</tt> if this set contains all of the elements of the
-     * specified collection.  If the specified collection is also a set, this
+     * specified collection. If the specified collection is also a set, this
      * method returns <tt>true</tt> if it is a <i>subset</i> of this set.
-     *
-     * @param  c collection to be checked for containment in this set
+     * 
+     * @param c collection to be checked for containment in this set
      * @return <tt>true</tt> if this set contains all of the elements of the
-    *         specified collection
+     * specified collection
      * @throws NullPointerException if the specified collection is null
      * @see #contains(Object)
      */
@@ -251,13 +225,13 @@
 
     /**
      * Adds all of the elements in the specified collection to this set if
-     * they're not already present.  If the specified collection is also a
+     * they're not already present. If the specified collection is also a
      * set, the <tt>addAll</tt> operation effectively modifies this set so
-     * that its value is the <i>union</i> of the two sets.  The behavior of
+     * that its value is the <i>union</i> of the two sets. The behavior of
      * this operation is undefined if the specified collection is modified
      * while the operation is in progress.
-     *
-     * @param  c collection containing elements to be added to this set
+     * 
+     * @param c collection containing elements to be added to this set
      * @return <tt>true</tt> if this set changed as a result of the call
      * @throws NullPointerException if the specified collection is null
      * @see #add(Object)
@@ -268,17 +242,17 @@
 
     /**
      * Removes from this set all of its elements that are contained in the
-     * specified collection.  If the specified collection is also a set,
+     * specified collection. If the specified collection is also a set,
      * this operation effectively modifies this set so that its value is the
      * <i>asymmetric set difference</i> of the two sets.
-     *
-     * @param  c collection containing elements to be removed from this set
+     * 
+     * @param c collection containing elements to be removed from this set
      * @return <tt>true</tt> if this set changed as a result of the call
      * @throws ClassCastException if the class of an element of this set
-     *         is incompatible with the specified collection (optional)
+     * is incompatible with the specified collection(optional)
      * @throws NullPointerException if this set contains a null element and the
-     *         specified collection does not permit null elements (optional),
-     *         or if the specified collection is null
+     * specified collection does not permit null elements(optional),
+     * or if the specified collection is null
      * @see #remove(Object)
      */
     public boolean removeAll(Collection c) {
@@ -287,19 +261,19 @@
 
     /**
      * Retains only the elements in this set that are contained in the
-     * specified collection.  In other words, removes from this set all of
-     * its elements that are not contained in the specified collection.  If
+     * specified collection. In other words, removes from this set all of
+     * its elements that are not contained in the specified collection. If
      * the specified collection is also a set, this operation effectively
      * modifies this set so that its value is the <i>intersection</i> of the
      * two sets.
-     *
-     * @param  c collection containing elements to be retained in this set
+     * 
+     * @param c collection containing elements to be retained in this set
      * @return <tt>true</tt> if this set changed as a result of the call
      * @throws ClassCastException if the class of an element of this set
-     *         is incompatible with the specified collection (optional)
+     * is incompatible with the specified collection(optional)
      * @throws NullPointerException if this set contains a null element and the
-     *         specified collection does not permit null elements (optional),
-     *         or if the specified collection is null
+     * specified collection does not permit null elements(optional),
+     * or if the specified collection is null
      * @see #remove(Object)
      */
     public boolean retainAll(Collection c) {
@@ -309,12 +283,11 @@
     /**
      * Returns an iterator over the elements contained in this set
      * in the order in which these elements were added.
-     *
-     * <p>The returned iterator provides a snapshot of the state of the set
+     *  The returned iterator provides a snapshot of the state of the set
      * when the iterator was constructed. No synchronization is needed while
      * traversing the iterator. The iterator does <em>NOT</em> support the
      * <tt>remove</tt> method.
-     *
+     * 
      * @return an iterator over the elements in this set
      */
     public Iterator iterator() {
@@ -327,57 +300,45 @@
      * as this object, or if it is also a {@link Set} and the elements
      * returned by an {@linkplain List#iterator() iterator} over the
      * specified set are the same as the elements returned by an
-     * iterator over this set.  More formally, the two iterators are
+     * iterator over this set. More formally, the two iterators are
      * considered to return the same elements if they return the same
      * number of elements and for every element {@code e1} returned by
      * the iterator over the specified set, there is an element
      * {@code e2} returned by the iterator over this set such that
-     * {@code (e1==null ? e2==null : e1.equals(e2))}.
-     *
+     * {@code(e1==null ? e2==null : e1.equals(e2))}.
+     * 
      * @param o object to be compared for equality with this set
      * @return {@code true} if the specified object is equal to this set
      */
     public boolean equals(Object o) {
-        if (o == this) {
+        if (o == this)
             return true;
-        }
-
-        if (!(o instanceof Set)) {
+        if (!(o instanceof Set))
             return false;
-        }
-
-        Set set = (Set) (o);
-        Iterator it = set.iterator();
+        Set set = (Set)(o);
+    Iterator it = set.iterator();
 
         // Uses O(n^2) algorithm that is only appropriate
         // for small sets, which CopyOnWriteArraySets should be.
 
         //  Use a single snapshot of underlying array
-        Object[] elements = al.getArray();
-        int len = elements.length;
-
+    Object[] elements = al.getArray();
+    int len = elements.length;
         // Mark matched elements to avoid re-checking
         boolean[] matched = new boolean[len];
         int k = 0;
-outer: 
-        while (it.hasNext()) {
-            if (++k > len) {
+        outer: while (it.hasNext()) {
+            if (++k > len)
                 return false;
-            }
-
             Object x = it.next();
-
             for (int i = 0; i < len; ++i) {
                 if (!matched[i] && eq(x, elements[i])) {
                     matched[i] = true;
-
-                    continue outer;
+            continue outer;
                 }
             }
-
-            return false;
+        return false;
         }
-
         return k == len;
     }
 
@@ -385,6 +346,6 @@
      * Test for equality, coping with nulls.
      */
     private static boolean eq(Object o1, Object o2) {
-        return ((o1 == null) ? (o2 == null) : o1.equals(o2));
+        return(o1 == null ? o2 == null : o1.equals(o2));
     }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOCondVar.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOCondVar.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOCondVar.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOCondVar.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ *  Licensed 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
+ *  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.
  */
-
 /*
  * Originally written by Doug Lea and released into the public domain.
  * This may be used for any purposes whatsoever without acknowledgment.
@@ -24,15 +20,13 @@
 
 import java.util.*;
 
-
 class FIFOCondVar extends CondVar implements Condition, java.io.Serializable {
-    private static final WaitQueue.QueuedSync sync = new WaitQueue.QueuedSync() {
-            public boolean recheck(WaitQueue.WaitNode node) {
-                return false;
-            }
 
-            public void takeOver(WaitQueue.WaitNode node) {
-            }
+    private static final WaitQueue.QueuedSync sync =
+        new WaitQueue.QueuedSync() {
+            public boolean recheck(WaitQueue.WaitNode node) { return false; }
+
+            public void takeOver(WaitQueue.WaitNode node) {}
         };
 
     // wait queue; only accessed when holding the lock
@@ -48,93 +42,67 @@
 
     public void awaitUninterruptibly() {
         int holdCount = lock.getHoldCount();
-
         if (holdCount == 0) {
             throw new IllegalMonitorStateException();
         }
-
         WaitQueue.WaitNode n = new WaitQueue.WaitNode();
         wq.insert(n);
-
-        for (int i = holdCount; i > 0; i--)
-            lock.unlock();
-
+        for (int i=holdCount; i>0; i--) lock.unlock();
         try {
             n.doWaitUninterruptibly(sync);
-        } finally {
-            for (int i = holdCount; i > 0; i--)
-                lock.lock();
+        }
+        finally {
+            for (int i=holdCount; i>0; i--) lock.lock();
         }
     }
 
     public void await() throws InterruptedException {
         int holdCount = lock.getHoldCount();
-
         if (holdCount == 0) {
             throw new IllegalMonitorStateException();
         }
-
-        if (Thread.interrupted()) {
-            throw new InterruptedException();
-        }
-
+        if (Thread.interrupted()) throw new InterruptedException();
         WaitQueue.WaitNode n = new WaitQueue.WaitNode();
         wq.insert(n);
-
-        for (int i = holdCount; i > 0; i--)
-            lock.unlock();
-
+        for (int i=holdCount; i>0; i--) lock.unlock();
         try {
             n.doWait(sync);
-        } finally {
-            for (int i = holdCount; i > 0; i--)
-                lock.lock();
+        }
+        finally {
+            for (int i=holdCount; i>0; i--) lock.lock();
         }
     }
 
     public boolean await(long timeout, TimeUnit unit)
         throws InterruptedException {
         int holdCount = lock.getHoldCount();
-
         if (holdCount == 0) {
             throw new IllegalMonitorStateException();
         }
-
-        if (Thread.interrupted()) {
-            throw new InterruptedException();
-        }
-
+        if (Thread.interrupted()) throw new InterruptedException();
         long nanos = unit.toNanos(timeout);
         WaitQueue.WaitNode n = new WaitQueue.WaitNode();
         wq.insert(n);
-
         boolean success = false;
-
-        for (int i = holdCount; i > 0; i--)
-            lock.unlock();
-
+        for (int i=holdCount; i>0; i--) lock.unlock();
         try {
             success = n.doTimedWait(sync, nanos);
-        } finally {
-            for (int i = holdCount; i > 0; i--)
-                lock.lock();
         }
-
+        finally {
+            for (int i=holdCount; i>0; i--) lock.lock();
+        }
         return success;
     }
 
-    //    public long awaitNanos(long timeout) throws InterruptedException {
-    //        throw new UnsupportedOperationException();
-    //    }
-    public boolean awaitUntil(Date deadline) throws InterruptedException {
-        if (deadline == null) {
-            throw new NullPointerException();
-        }
+//    public long awaitNanos(long timeout) throws InterruptedException {
+//        throw new UnsupportedOperationException();
+//    }
 
+    public boolean awaitUntil(Date deadline) throws InterruptedException {
+        if (deadline == null) throw new NullPointerException();
         long abstime = deadline.getTime();
         long start = System.currentTimeMillis();
         long msecs = abstime - start;
-
         return await(msecs, TimeUnit.MILLISECONDS);
     }
 
@@ -142,17 +110,10 @@
         if (!lock.isHeldByCurrentThread()) {
             throw new IllegalMonitorStateException();
         }
-
         for (;;) {
             WaitQueue.WaitNode w = wq.extract();
-
-            if (w == null) {
-                return; // no one to signal
-            }
-
-            if (w.signal(sync)) {
-                return; // notify if still waiting, else skip
-            }
+            if (w == null) return;  // no one to signal
+            if (w.signal(sync)) return; // notify if still waiting, else skip
         }
     }
 
@@ -160,14 +121,9 @@
         if (!lock.isHeldByCurrentThread()) {
             throw new IllegalMonitorStateException();
         }
-
         for (;;) {
             WaitQueue.WaitNode w = wq.extract();
-
-            if (w == null) {
-                return; // no more to signal
-            }
-
+            if (w == null) return;  // no more to signal
             w.signal(sync);
         }
     }
@@ -176,7 +132,6 @@
         if (!lock.isHeldByCurrentThread()) {
             throw new IllegalMonitorStateException();
         }
-
         return wq.hasNodes();
     }
 
@@ -184,7 +139,6 @@
         if (!lock.isHeldByCurrentThread()) {
             throw new IllegalMonitorStateException();
         }
-
         return wq.getLength();
     }
 
@@ -192,7 +146,6 @@
         if (!lock.isHeldByCurrentThread()) {
             throw new IllegalMonitorStateException();
         }
-
         return wq.getWaitingThreads();
     }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOWaitQueue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOWaitQueue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOWaitQueue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/FIFOWaitQueue.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ *  Licensed 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
+ *  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.
  */
-
 /*
  * Written by Doug Lea with assistance from members of JCP JSR-166
  * Expert Group and released to the public domain, as explained at
@@ -23,42 +19,36 @@
 
 import java.util.*;
 
-
 /**
  * Simple linked list queue used in FIFOSemaphore.
  * Methods are not synchronized; they depend on synch of callers.
- * Must be public, since it is used by Semaphore (outside this package).
+ * Must be public, since it is used by Semaphore(outside this package).
  * NOTE: this class is NOT present in java.util.concurrent.
  */
 class FIFOWaitQueue extends WaitQueue implements java.io.Serializable {
     protected transient WaitNode head_ = null;
     protected transient WaitNode tail_ = null;
 
-    public FIFOWaitQueue() {
-    }
+    public FIFOWaitQueue() {}
 
     public void insert(WaitNode w) {
-        if (tail_ == null) {
+        if (tail_ == null)
             head_ = tail_ = w;
-        } else {
+        else {
             tail_.next = w;
             tail_ = w;
         }
     }
 
     public WaitNode extract() {
-        if (head_ == null) {
+        if (head_ == null)
             return null;
-        } else {
+        else {
             WaitNode w = head_;
             head_ = w.next;
-
-            if (head_ == null) {
+            if (head_ == null)
                 tail_ = null;
-            }
-
             w.next = null;
-
             return w;
         }
     }
@@ -70,15 +60,10 @@
     public int getLength() {
         int count = 0;
         WaitNode node = head_;
-
         while (node != null) {
-            if (node.waiting) {
-                count++;
-            }
-
+            if (node.waiting) count++;
             node = node.next;
         }
-
         return count;
     }
 
@@ -86,29 +71,18 @@
         List list = new ArrayList();
         int count = 0;
         WaitNode node = head_;
-
         while (node != null) {
-            if (node.waiting) {
-                list.add(node.owner);
-            }
-
+            if (node.waiting) list.add(node.owner);
             node = node.next;
         }
-
         return list;
     }
 
     public boolean isWaiting(Thread thread) {
-        if (thread == null) {
-            throw new NullPointerException();
-        }
-
+        if (thread == null) throw new NullPointerException();
         for (WaitNode node = head_; node != null; node = node.next) {
-            if (node.waiting && (node.owner == thread)) {
-                return true;
-            }
+            if (node.waiting && node.owner == thread) return true;
         }
-
         return false;
     }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Lock.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Lock.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Lock.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Lock.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ *  Licensed 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
+ *  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.
  */
-
 /*
  * Written by Doug Lea with assistance from members of JCP JSR-166
  * Expert Group and released to the public domain, as explained at
@@ -21,30 +17,25 @@
  */
 package org.apache.openjpa.lib.util.concurrent;
 
-
 /**
  * <tt>Lock</tt> implementations provide more extensive locking
  * operations than can be obtained using <tt>synchronized</tt> methods
- * and statements.  They allow more flexible structuring, may have
+ * and statements. They allow more flexible structuring, may have
  * quite different properties, and may support multiple associated
  * {@link Condition} objects.
- *
- * <p>A lock is a tool for controlling access to a shared resource by
+ *  A lock is a tool for controlling access to a shared resource by
  * multiple threads. Commonly, a lock provides exclusive access to a
  * shared resource: only one thread at a time can acquire the lock and
  * all access to the shared resource requires that the lock be
  * acquired first. However, some locks may allow concurrent access to
- * a shared resource, such as the read lock of a {@link
- * ReadWriteLock}.
- *
- * <p>The use of <tt>synchronized</tt> methods or statements provides
+ * a shared resource, such as the read lock of a {@link ReadWriteLock}.
+ *  The use of <tt>synchronized</tt> methods or statements provides
  * access to the implicit monitor lock associated with every object, but
  * forces all lock acquisition and release to occur in a block-structured way:
  * when multiple locks are acquired they must be released in the opposite
  * order, and all locks must be released in the same lexical scope in which
  * they were acquired.
- *
- * <p>While the scoping mechanism for <tt>synchronized</tt> methods
+ *  While the scoping mechanism for <tt>synchronized</tt> methods
  * and statements makes it much easier to program with monitor locks,
  * and helps avoid many common programming errors involving locks,
  * there are occasions where you need to work with locks in a more
@@ -52,115 +43,98 @@
  * concurrently accessed data structures require the use of
  * &quot;hand-over-hand&quot; or &quot;chain locking&quot;: you
  * acquire the lock of node A, then node B, then release A and acquire
- * C, then release B and acquire D and so on.  Implementations of the
+ * C, then release B and acquire D and so on. Implementations of the
  * <tt>Lock</tt> interface enable the use of such techniques by
  * allowing a lock to be acquired and released in different scopes,
- * and allowing multiple locks to be acquired and released in any
- * order.
- *
- * <p>With this increased flexibility comes additional
+ * and allowing multiple locks to be acquired and released in any order.
+ *  With this increased flexibility comes additional
  * responsibility. The absence of block-structured locking removes the
  * automatic release of locks that occurs with <tt>synchronized</tt>
- * methods and statements. In most cases, the following idiom
- * should be used:
- *
- * <pre><tt>     Lock l = ...;
- *     l.lock();
- *     try {
- *         // access the resource protected by this lock
- *     } finally {
- *         l.unlock();
- *     }
+ * methods and statements. In most cases, the following idiom should be used:
+ * 
+ * <pre><tt> Lock l = ...; l.lock(); try {
+ * // access the resource protected by this lock } finally { l.unlock(); }
  * </tt></pre>
- *
- * When locking and unlocking occur in different scopes, care must be
+ *  When locking and unlocking occur in different scopes, care must be
  * taken to ensure that all code that is executed while the lock is
  * held is protected by try-finally or try-catch to ensure that the
  * lock is released when necessary.
- *
- * <p><tt>Lock</tt> implementations provide additional functionality
+ * 
+ * <tt>Lock</tt> implementations provide additional functionality
  * over the use of <tt>synchronized</tt> methods and statements by
- * providing a non-blocking attempt to acquire a lock ({@link
+ * providing a non-blocking attempt to acquire a lock({@link
  * #tryLock()}), an attempt to acquire the lock that can be
- * interrupted ({@link #lockInterruptibly}, and an attempt to acquire
- * the lock that can timeout ({@link #tryLock(long, TimeUnit)}).
- *
- * <p>A <tt>Lock</tt> class can also provide behavior and semantics
+ * interrupted({@link #lockInterruptibly}, and an attempt to acquire
+ * the lock that can timeout({@link #tryLock(long, TimeUnit)}).
+ *  A <tt>Lock</tt> class can also provide behavior and semantics
  * that is quite different from that of the implicit monitor lock,
  * such as guaranteed ordering, non-reentrant usage, or deadlock
  * detection. If an implementation provides such specialized semantics
  * then the implementation must document those semantics.
- *
- * <p>Note that <tt>Lock</tt> instances are just normal objects and can
+ *  Note that <tt>Lock</tt> instances are just normal objects and can
  * themselves be used as the target in a <tt>synchronized</tt> statement.
  * Acquiring the
  * monitor lock of a <tt>Lock</tt> instance has no specified relationship
  * with invoking any of the {@link #lock} methods of that instance.
  * It is recommended that to avoid confusion you never use <tt>Lock</tt>
  * instances in this way, except within their own implementation.
- *
- * <p>Except where noted, passing a <tt>null</tt> value for any
- * parameter will result in a {@link NullPointerException} being
- * thrown.
- *
+ *  Except where noted, passing a <tt>null</tt> value for any
+ * parameter will result in a {@link NullPointerException} being thrown.
+ * 
  * <h3>Memory Synchronization</h3>
- * <p>All <tt>Lock</tt> implementations <em>must</em> enforce the same
+ * All <tt>Lock</tt> implementations <em>must</em> enforce the same
  * memory synchronization semantics as provided by the built-in monitor
  * lock, as described in <a href="http://java.sun.com/docs/books/jls/">
- * The Java Language Specification, Third Edition (17.4 Memory Model)</a>:
+ * The Java Language Specification, Third Edition(17.4 Memory Model)</a>:
  * <ul>
  * <li>A successful <tt>lock</tt> operation has the same memory
  * synchronization effects as a successful <em>Lock</em> action.
  * <li>A successful <tt>unlock</tt> operation has the same
  * memory synchronization effects as a successful <em>Unlock</em> action.
  * </ul>
- *
- * Unsuccessful locking and unlocking operations, and reentrant
+ *  Unsuccessful locking and unlocking operations, and reentrant
  * locking/unlocking operations, do not require any memory
  * synchronization effects.
- *
+ * 
  * <h3>Implementation Considerations</h3>
- *
- * <p> The three forms of lock acquisition (interruptible,
+ *   The three forms of lock acquisition(interruptible,
  * non-interruptible, and timed) may differ in their performance
  * characteristics, ordering guarantees, or other implementation
- * qualities.  Further, the ability to interrupt the <em>ongoing</em>
+ * qualities. Further, the ability to interrupt the <em>ongoing</em>
  * acquisition of a lock may not be available in a given <tt>Lock</tt>
- * class.  Consequently, an implementation is not required to define
+ * class. Consequently, an implementation is not required to define
  * exactly the same guarantees or semantics for all three forms of
  * lock acquisition, nor is it required to support interruption of an
- * ongoing lock acquisition.  An implementation is required to clearly
+ * ongoing lock acquisition. An implementation is required to clearly
  * document the semantics and guarantees provided by each of the
  * locking methods. It must also obey the interruption semantics as
  * defined in this interface, to the extent that interruption of lock
- * acquisition is supported: which is either totally, or only on
- * method entry.
- *
- * <p>As interruption generally implies cancellation, and checks for
+ * acquisition is supported: which is either totally, or only on method entry.
+ *  As interruption generally implies cancellation, and checks for
  * interruption are often infrequent, an implementation can favor responding
  * to an interrupt over normal method return. This is true even if it can be
  * shown that the interrupt occurred after another action may have unblocked
  * the thread. An implementation should document this behavior.
- *
- *
+ * 
+ * 
  * @see ReentrantLock
  * @see Condition
  * @see ReadWriteLock
- *
+ * 
  * @since 1.5
  * @author Doug Lea
- *
+ * 
  */
 public interface Lock {
+
     /**
-     * Acquires the lock.
-     * <p>If the lock is not available then
+     * Acquires the lock. If the lock is not available then
      * the current thread becomes disabled for thread scheduling
      * purposes and lies dormant until the lock has been acquired.
-     * <p><b>Implementation Considerations</b>
-     * <p>A <tt>Lock</tt> implementation may be able to detect
+     * <b>Implementation Considerations</b>
+     * A <tt>Lock</tt> implementation may be able to detect
      * erroneous use of the lock, such as an invocation that would cause
-     * deadlock, and may throw an (unchecked) exception in such circumstances.
+     * deadlock, and may throw an(unchecked) exception in such circumstances.
      * The circumstances and the exception type must be documented by that
      * <tt>Lock</tt> implementation.
      */
@@ -169,16 +143,15 @@
     /**
      * Acquires the lock unless the current thread is
      * {@link Thread#interrupt interrupted}.
-     * <p>Acquires the lock if it is available and returns immediately.
-     * <p>If the lock is not available then
+     * Acquires the lock if it is available and returns immediately.
+     * If the lock is not available then
      * the current thread becomes disabled for thread scheduling
      * purposes and lies dormant until one of two things happens:
      * <ul>
      * <li>The lock is acquired by the current thread; or
      * <li>Some other thread {@link Thread#interrupt interrupts} the current
      * thread, and interruption of lock acquisition is supported.
-     * </ul>
-     * <p>If the current thread:
+     * </ul> If the current thread:
      * <ul>
      * <li>has its interrupted status set on entry to this method; or
      * <li>is {@link Thread#interrupt interrupted} while acquiring
@@ -186,54 +159,42 @@
      * </ul>
      * then {@link InterruptedException} is thrown and the current thread's
      * interrupted status is cleared.
-     *
-     * <p><b>Implementation Considerations</b>
-     *
-     * <p>The ability to interrupt a lock acquisition in some
+     * 
+     * <b>Implementation Considerations</b>
+     *  The ability to interrupt a lock acquisition in some
      * implementations may not be possible, and if possible may be an
-     * expensive operation.  The programmer should be aware that this
-     * may be the case. An implementation should document when this is
-     * the case.
-     *
-     * <p>An implementation can favor responding to an interrupt over
+     * expensive operation. The programmer should be aware that this
+     * may be the case. An implementation should document when this is the case.
+     *  An implementation can favor responding to an interrupt over
      * normal method return.
-     *
-     * <p>A <tt>Lock</tt> implementation may be able to detect
+     *  A <tt>Lock</tt> implementation may be able to detect
      * erroneous use of the lock, such as an invocation that would
-     * cause deadlock, and may throw an (unchecked) exception in such
-     * circumstances.  The circumstances and the exception type must
+     * cause deadlock, and may throw an(unchecked) exception in such
+     * circumstances. The circumstances and the exception type must
      * be documented by that <tt>Lock</tt> implementation.
-     *
+     * 
      * @throws InterruptedException if the current thread is interrupted
-     * while acquiring the lock (and interruption of lock acquisition is
+     * while acquiring the lock(and interruption of lock acquisition is
      * supported).
-     *
+     * 
      * @see Thread#interrupt
      */
     void lockInterruptibly() throws InterruptedException;
 
     /**
      * Acquires the lock only if it is free at the time of invocation.
-     * <p>Acquires the lock if it is available and returns immediately
+     * Acquires the lock if it is available and returns immediately
      * with the value <tt>true</tt>.
      * If the lock is not available then this method will return
      * immediately with the value <tt>false</tt>.
-     * <p>A typical usage idiom for this method would be:
-     * <pre>
-     *      Lock lock = ...;
-     *      if (lock.tryLock()) {
-     *          try {
-     *              // manipulate protected state
-     *          } finally {
-     *              lock.unlock();
-     *          }
-     *      } else {
-     *          // perform alternative actions
-     *      }
+     * A typical usage idiom for this method would be:
+     * <pre> Lock lock = ...; if (lock.tryLock()) { try {
+     * // manipulate protected state } finally { lock.unlock(); } } else {
+     * // perform alternative actions }
      * </pre>
      * This usage ensures that the lock is unlocked if it was acquired, and
      * doesn't try to unlock if the lock was not acquired.
-     *
+     * 
      * @return <tt>true</tt> if the lock was acquired and <tt>false</tt>
      * otherwise.
      */
@@ -242,10 +203,8 @@
     /**
      * Acquires the lock if it is free within the given waiting time and the
      * current thread has not been {@link Thread#interrupt interrupted}.
-     *
-     * <p>If the lock is available this method returns immediately
-     * with the value <tt>true</tt>.
-     * If the lock is not available then
+     *  If the lock is available this method returns immediately
+     * with the value <tt>true</tt>. If the lock is not available then
      * the current thread becomes disabled for thread scheduling
      * purposes and lies dormant until one of three things happens:
      * <ul>
@@ -253,9 +212,8 @@
      * <li>Some other thread {@link Thread#interrupt interrupts} the current
      * thread, and interruption of lock acquisition is supported; or
      * <li>The specified waiting time elapses
-     * </ul>
-     * <p>If the lock is acquired then the value <tt>true</tt> is returned.
-     * <p>If the current thread:
+     * </ul> If the lock is acquired then the value <tt>true</tt> is returned.
+     * If the current thread:
      * <ul>
      * <li>has its interrupted status set on entry to this method; or
      * <li>is {@link Thread#interrupt interrupted} while acquiring
@@ -263,45 +221,43 @@
      * </ul>
      * then {@link InterruptedException} is thrown and the current thread's
      * interrupted status is cleared.
-     * <p>If the specified waiting time elapses then the value <tt>false</tt>
-     * is returned.
-     * If the time is
+     * If the specified waiting time elapses then the value <tt>false</tt>
+     * is returned. If the time is
      * less than or equal to zero, the method will not wait at all.
-     *
-     * <p><b>Implementation Considerations</b>
-     * <p>The ability to interrupt a lock acquisition in some implementations
-     * may not be possible, and if possible may
-     * be an expensive operation.
+     * 
+     * <b>Implementation Considerations</b>
+     * The ability to interrupt a lock acquisition in some implementations
+     * may not be possible, and if possible may be an expensive operation.
      * The programmer should be aware that this may be the case. An
      * implementation should document when this is the case.
-     * <p>An implementation can favor responding to an interrupt over normal
+     * An implementation can favor responding to an interrupt over normal
      * method return, or reporting a timeout.
-     * <p>A <tt>Lock</tt> implementation may be able to detect
+     * A <tt>Lock</tt> implementation may be able to detect
      * erroneous use of the lock, such as an invocation that would cause
-     * deadlock, and may throw an (unchecked) exception in such circumstances.
+     * deadlock, and may throw an(unchecked) exception in such circumstances.
      * The circumstances and the exception type must be documented by that
      * <tt>Lock</tt> implementation.
-     *
+     * 
      * @param time the maximum time to wait for the lock
      * @param unit the time unit of the <tt>time</tt> argument.
      * @return <tt>true</tt> if the lock was acquired and <tt>false</tt>
      * if the waiting time elapsed before the lock was acquired.
-     *
+     * 
      * @throws InterruptedException if the current thread is interrupted
-     * while acquiring the lock (and interruption of lock acquisition is
+     * while acquiring the lock(and interruption of lock acquisition is
      * supported).
-     *
+     * 
      * @see Thread#interrupt
      */
     boolean tryLock(long time, TimeUnit unit) throws InterruptedException;
 
     /**
      * Releases the lock.
-     * <p><b>Implementation Considerations</b>
-     * <p>A <tt>Lock</tt> implementation will usually impose
-     * restrictions on which thread can release a lock (typically only the
+     * <b>Implementation Considerations</b>
+     * A <tt>Lock</tt> implementation will usually impose
+     * restrictions on which thread can release a lock(typically only the
      * holder of the lock can release it) and may throw
-     * an (unchecked) exception if the restriction is violated.
+     * an(unchecked) exception if the restriction is violated.
      * Any restrictions and the exception
      * type must be documented by that <tt>Lock</tt> implementation.
      */
@@ -310,17 +266,16 @@
     /**
      * Returns a new {@link Condition} instance that is bound to this
      * <tt>Lock</tt> instance.
-     * <p>Before waiting on the condition the lock must be held by the
+     * Before waiting on the condition the lock must be held by the
      * current thread.
      * A call to {@link Condition#await()} will atomically release the lock
      * before waiting and re-acquire the lock before the wait returns.
-     * <p><b>Implementation Considerations</b>
-     * <p>The exact operation of the {@link Condition} instance depends on the
+     * <b>Implementation Considerations</b>
+     * The exact operation of the {@link Condition} instance depends on the
      * <tt>Lock</tt> implementation and must be documented by that
      * implementation.
-     *
-     * @return A new {@link Condition} instance for this <tt>Lock</tt>
-     * instance.
+     * 
+     * @return A new {@link Condition} instance for this <tt>Lock</tt> instance.
      * @throws UnsupportedOperationException if this <tt>Lock</tt>
      * implementation does not support conditions.
      */

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/NanoTimer.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/NanoTimer.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/NanoTimer.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/NanoTimer.java Fri Jun 30 15:37:18 2006
@@ -1,29 +1,24 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ *  Licensed 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
+ *  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.
  */
-
 /*
  * Written by Dawid Kurzyniec and released to the public domain, as explained
  * at http://creativecommons.org/licenses/publicdomain
  */
 package org.apache.openjpa.lib.util.concurrent;
 
-
 /**
  * Interface to specify custom implementation of precise timer.
- *
+ * 
  * @author Dawid Kurzyniec
  * @version 1.0
  */
@@ -33,13 +28,13 @@
      * in nanoseconds. This method can only be used to measure elapsed time and
      * is not related to any other notion of system or wall-clock time. The
      * value returned represents nanoseconds since some fixed but arbitrary
-     * time (perhaps in the future, so values may be negative). This method
+     * time(perhaps in the future, so values may be negative). This method
      * provides nanosecond precision, but not necessarily nanosecond accuracy.
      * No guarantees are made about how frequently values change. Differences
      * in successive calls that span greater than approximately 292 years
      * (263 nanoseconds) will not accurately compute elapsed time due to
      * numerical overflow.
-     *
+     * 
      * @return The current value of the system timer, in nanoseconds.
      */
     long nanoTime();

Modified: incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Queue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Queue.java?rev=418401&r1=418400&r2=418401&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Queue.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Queue.java Fri Jun 30 15:37:18 2006
@@ -1,19 +1,15 @@
 /*
  * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ *  Licensed 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
+ *  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.
  */
-
 /*
  * Written by Doug Lea with assistance from members of JCP JSR-166
  * Expert Group and released to the public domain, as explained at
@@ -23,64 +19,59 @@
 
 import java.util.*;
 
-
 /**
  * A collection designed for holding elements prior to processing.
  * Besides basic {@link java.util.Collection Collection} operations,
  * queues provide additional insertion, extraction, and inspection
- * operations.  Each of these methods exists in two forms: one throws
+ * operations. Each of these methods exists in two forms: one throws
  * an exception if the operation fails, the other returns a special
- * value (either <tt>null</tt> or <tt>false</tt>, depending on the
- * operation).  The latter form of the insert operation is designed
+ * value(either <tt>null</tt> or <tt>false</tt>, depending on the
+ * operation). The latter form of the insert operation is designed
  * specifically for use with capacity-restricted <tt>Queue</tt>
- * implementations; in most implementations, insert operations cannot
- * fail.
- *
- * <p>
+ * implementations; in most implementations, insert operations cannot fail.
+ * 
+ * 
  * <table BORDER CELLPADDING=3 CELLSPACING=1>
- *  <tr>
- *    <td></td>
- *    <td ALIGN=CENTER><em>Throws exception</em></td>
- *    <td ALIGN=CENTER><em>Returns special value</em></td>
- *  </tr>
- *  <tr>
- *    <td><b>Insert</b></td>
- *    <td>{@link #add add(e)}</td>
- *    <td>{@link #offer offer(e)}</td>
- *  </tr>
- *  <tr>
- *    <td><b>Remove</b></td>
- *    <td>{@link #remove remove()}</td>
- *    <td>{@link #poll poll()}</td>
- *  </tr>
- *  <tr>
- *    <td><b>Examine</b></td>
- *    <td>{@link #element element()}</td>
- *    <td>{@link #peek peek()}</td>
- *  </tr>
+ * <tr>
+ * <td></td>
+ * <td ALIGN=CENTER><em>Throws exception</em></td>
+ * <td ALIGN=CENTER><em>Returns special value</em></td>
+ * </tr>
+ * <tr>
+ * <td><b>Insert</b></td>
+ * <td>{@link #add add(e)}</td>
+ * <td>{@link #offer offer(e)}</td>
+ * </tr>
+ * <tr>
+ * <td><b>Remove</b></td>
+ * <td>{@link #remove remove()}</td>
+ * <td>{@link #poll poll()}</td>
+ * </tr>
+ * <tr>
+ * <td><b>Examine</b></td>
+ * <td>{@link #element element()}</td>
+ * <td>{@link #peek peek()}</td>
+ * </tr>
  * </table>
- *
- * <p>Queues typically, but do not necessarily, order elements in a
- * FIFO (first-in-first-out) manner.  Among the exceptions are
+ *  Queues typically, but do not necessarily, order elements in a
+ * FIFO(first-in-first-out) manner. Among the exceptions are
  * priority queues, which order elements according to a supplied
- * comparator, or the elements' natural ordering, and LIFO queues (or
- * stacks) which order the elements LIFO (last-in-first-out).
+ * comparator, or the elements' natural ordering, and LIFO queues(or
+ * stacks) which order the elements LIFO(last-in-first-out).
  * Whatever the ordering used, the <em>head</em> of the queue is that
  * element which would be removed by a call to {@link #remove() } or
- * {@link #poll()}.  In a FIFO queue, all new elements are inserted at
+ * {@link #poll()}. In a FIFO queue, all new elements are inserted at
  * the <em> tail</em> of the queue. Other kinds of queues may use
- * different placement rules.  Every <tt>Queue</tt> implementation
+ * different placement rules. Every <tt>Queue</tt> implementation
  * must specify its ordering properties.
- *
- * <p>The {@link #offer offer} method inserts an element if possible,
- * otherwise returning <tt>false</tt>.  This differs from the {@link
+ *  The {@link #offer offer} method inserts an element if possible,
+ * otherwise returning <tt>false</tt>. This differs from the {@link
  * java.util.Collection#add Collection.add} method, which can fail to
- * add an element only by throwing an unchecked exception.  The
+ * add an element only by throwing an unchecked exception. The
  * <tt>offer</tt> method is designed for use when failure is a normal,
  * rather than exceptional occurrence, for example, in fixed-capacity
  * (or &quot;bounded&quot;) queues.
- *
- * <p>The {@link #remove()} and {@link #poll()} methods remove and
+ *  The {@link #remove()} and {@link #poll()} methods remove and
  * return the head of the queue.
  * Exactly which element is removed from the queue is a
  * function of the queue's ordering policy, which differs from
@@ -88,36 +79,33 @@
  * <tt>poll()</tt> methods differ only in their behavior when the
  * queue is empty: the <tt>remove()</tt> method throws an exception,
  * while the <tt>poll()</tt> method returns <tt>null</tt>.
- *
- * <p>The {@link #element()} and {@link #peek()} methods return, but do
+ *  The {@link #element()} and {@link #peek()} methods return, but do
  * not remove, the head of the queue.
- *
- * <p>The <tt>Queue</tt> interface does not define the <i>blocking queue
- * methods</i>, which are common in concurrent programming.  These methods,
+ *  The <tt>Queue</tt> interface does not define the <i>blocking queue
+ * methods</i>, which are common in concurrent programming. These methods,
  * which wait for elements to appear or for space to become available, are
  * defined in the {@link edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue} interface, which
  * extends this interface.
- *
- * <p><tt>Queue</tt> implementations generally do not allow insertion
+ * 
+ * <tt>Queue</tt> implementations generally do not allow insertion
  * of <tt>null</tt> elements, although some implementations, such as
  * {@link LinkedList}, do not prohibit insertion of <tt>null</tt>.
  * Even in the implementations that permit it, <tt>null</tt> should
  * not be inserted into a <tt>Queue</tt>, as <tt>null</tt> is also
  * used as a special return value by the <tt>poll</tt> method to
  * indicate that the queue contains no elements.
- *
- * <p><tt>Queue</tt> implementations generally do not define
+ * 
+ * <tt>Queue</tt> implementations generally do not define
  * element-based versions of methods <tt>equals</tt> and
  * <tt>hashCode</tt> but instead inherit the identity based versions
  * from class <tt>Object</tt>, because element-based equality is not
  * always well-defined for queues with the same elements but different
  * ordering properties.
- *
- *
- * <p>This interface is a member of the
+ * 
+ *  This interface is a member of the
  * <a href="{@docRoot}/../guide/collections/index.html">
  * Java Collections Framework</a>.
- *
+ * 
  * @see java.util.Collection
  * @see LinkedList
  * @see PriorityQueue
@@ -135,17 +123,17 @@
      * immediately without violating capacity restrictions, returning
      * <tt>true</tt> upon success and throwing an <tt>IllegalStateException</tt>
      * if no space is currently available.
-     *
+     * 
      * @param e the element to add
      * @return <tt>true</tt> (as specified by {@link Collection#add})
      * @throws IllegalStateException if the element cannot be added at this
-     *         time due to capacity restrictions
+     * time due to capacity restrictions
      * @throws ClassCastException if the class of the specified element
-     *         prevents it from being added to this queue
+     * prevents it from being added to this queue
      * @throws NullPointerException if the specified element is null and
-     *         this queue not permit null elements
+     * this queue not permit null elements
      * @throws IllegalArgumentException if some property of this element
-     *         prevents it from being added to this queue
+     * prevents it from being added to this queue
      */
     boolean add(Object e);
 
@@ -155,25 +143,24 @@
      * When using a capacity-restricted queue, this method is generally
      * preferable to {@link #add}, which can fail to insert an element only
      * by throwing an exception.
-     *
+     * 
      * @param e the element to add
      * @return <tt>true</tt> if the element was added to this queue, else
-     *         <tt>false</tt>
+     * <tt>false</tt>
      * @throws ClassCastException if the class of the specified element
-     *         prevents it from being added to this queue
+     * prevents it from being added to this queue
      * @throws NullPointerException if the specified element is null and
-     *         this queue does not permit null elements
+     * this queue does not permit null elements
      * @throws IllegalArgumentException if some property of this element
-     *         prevents it from being added to this queue
+     * prevents it from being added to this queue
      */
     boolean offer(Object e);
 
     /**
-     * Retrieves and removes the head of this queue.  This method differs
+     * Retrieves and removes the head of this queue. This method differs
      * from {@link #poll poll} only in that it throws an exception if this
-     * queue is empty.
-     * is empty.
-     *
+     * queue is empty. is empty.
+     * 
      * @return the head of this queue
      * @throws NoSuchElementException if this queue is empty
      */
@@ -182,16 +169,16 @@
     /**
      * Retrieves and removes the head of this queue,
      * or returns <tt>null</tt> if this queue is empty.
-     *
+     * 
      * @return the head of this queue, or <tt>null</tt> if this queue is empty
      */
     Object poll();
 
     /**
-     * Retrieves, but does not remove, the head of this queue.  This method
+     * Retrieves, but does not remove, the head of this queue. This method
      * differs from {@link #peek peek} only in that it throws an exception
      * if this queue is empty.
-     *
+     * 
      * @return the head of this queue
      * @throws NoSuchElementException if this queue is empty
      */
@@ -200,7 +187,7 @@
     /**
      * Retrieves, but does not remove, the head of this queue,
      * or returns <tt>null</tt> if this queue is empty.
-     *
+     * 
      * @return the head of this queue, or <tt>null</tt> if this queue is empty
      */
     Object peek();