7038885: Improved bulk operation disclaimers for concurrent collections
authordl
Fri, 22 Apr 2011 16:33:23 +0100
changeset 9515 04056ec0f477
parent 9514 bdb24db75fe8
child 9518 3032a5d46a9c
7038885: Improved bulk operation disclaimers for concurrent collections Reviewed-by: chegar
jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
jdk/src/share/classes/java/util/concurrent/LinkedTransferQueue.java
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Fri Apr 22 11:03:39 2011 +0100
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Fri Apr 22 16:33:23 2011 +0100
@@ -59,10 +59,17 @@
  * ConcurrentModificationException}, and may proceed concurrently with
  * other operations.
  *
- * <p>Beware that, unlike in most collections, the {@code size}
- * method is <em>NOT</em> a constant-time operation. Because of the
+ * <p>Beware that, unlike in most collections, the {@code size} method
+ * is <em>NOT</em> a constant-time operation. Because of the
  * asynchronous nature of these deques, determining the current number
- * of elements requires a traversal of the elements.
+ * of elements requires a traversal of the elements, and so may report
+ * inaccurate results if this collection is modified during traversal.
+ * Additionally, the bulk operations {@code addAll},
+ * {@code removeAll}, {@code retainAll}, {@code containsAll},
+ * {@code equals}, and {@code toArray} are <em>not</em> guaranteed
+ * to be performed atomically. For example, an iterator operating
+ * concurrently with an {@code addAll} operation might view only some
+ * of the added elements.
  *
  * <p>This class and its iterator implement all of the <em>optional</em>
  * methods of the {@link Deque} and {@link Iterator} interfaces.
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Fri Apr 22 11:03:39 2011 +0100
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Fri Apr 22 16:33:23 2011 +0100
@@ -72,7 +72,14 @@
  * <p>Beware that, unlike in most collections, the {@code size} method
  * is <em>NOT</em> a constant-time operation. Because of the
  * asynchronous nature of these queues, determining the current number
- * of elements requires a traversal of the elements.
+ * of elements requires a traversal of the elements, and so may report
+ * inaccurate results if this collection is modified during traversal.
+ * Additionally, the bulk operations {@code addAll},
+ * {@code removeAll}, {@code retainAll}, {@code containsAll},
+ * {@code equals}, and {@code toArray} are <em>not</em> guaranteed
+ * to be performed atomically. For example, an iterator operating
+ * concurrently with an {@code addAll} operation might view only some
+ * of the added elements.
  *
  * <p>This class and its iterator implement all of the <em>optional</em>
  * methods of the {@link Queue} and {@link Iterator} interfaces.
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Fri Apr 22 11:03:39 2011 +0100
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Fri Apr 22 16:33:23 2011 +0100
@@ -66,12 +66,13 @@
  * <p>Beware that, unlike in most collections, the <tt>size</tt>
  * method is <em>not</em> a constant-time operation. Because of the
  * asynchronous nature of these maps, determining the current number
- * of elements requires a traversal of the elements.  Additionally,
- * the bulk operations <tt>putAll</tt>, <tt>equals</tt>, and
- * <tt>clear</tt> are <em>not</em> guaranteed to be performed
- * atomically. For example, an iterator operating concurrently with a
- * <tt>putAll</tt> operation might view only some of the added
- * elements.
+ * of elements requires a traversal of the elements, and so may report
+ * inaccurate results if this collection is modified during traversal.
+ * Additionally, the bulk operations <tt>putAll</tt>, <tt>equals</tt>,
+ * <tt>toArray</tt>, <tt>containsValue</tt>, and <tt>clear</tt> are
+ * <em>not</em> guaranteed to be performed atomically. For example, an
+ * iterator operating concurrently with a <tt>putAll</tt> operation
+ * might view only some of the added elements.
  *
  * <p>This class and its views and iterators implement all of the
  * <em>optional</em> methods of the {@link Map} and {@link Iterator}
@@ -1661,7 +1662,9 @@
     /**
      * Returns <tt>true</tt> if this map maps one or more keys to the
      * specified value.  This operation requires time linear in the
-     * map size.
+     * map size. Additionally, it is possible for the map to change
+     * during execution of this method, in which case the returned
+     * result may be inaccurate.
      *
      * @param value value whose presence in this map is to be tested
      * @return <tt>true</tt> if a mapping to <tt>value</tt> exists;
@@ -1751,7 +1754,7 @@
      *
      * @return a navigable set view of the keys in this map
      */
-     public NavigableSet<K> keySet() {
+    public NavigableSet<K> keySet() {
         KeySet ks = keySet;
         return (ks != null) ? ks : (keySet = new KeySet(this));
     }
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Fri Apr 22 11:03:39 2011 +0100
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Fri Apr 22 16:33:23 2011 +0100
@@ -58,12 +58,14 @@
  * <p>Beware that, unlike in most collections, the <tt>size</tt>
  * method is <em>not</em> a constant-time operation. Because of the
  * asynchronous nature of these sets, determining the current number
- * of elements requires a traversal of the elements. Additionally, the
- * bulk operations <tt>addAll</tt>, <tt>removeAll</tt>,
- * <tt>retainAll</tt>, and <tt>containsAll</tt> are <em>not</em>
- * guaranteed to be performed atomically. For example, an iterator
- * operating concurrently with an <tt>addAll</tt> operation might view
- * only some of the added elements.
+ * of elements requires a traversal of the elements, and so may report
+ * inaccurate results if this collection is modified during traversal.
+ * Additionally, the bulk operations <tt>addAll</tt>,
+ * <tt>removeAll</tt>, <tt>retainAll</tt>, <tt>containsAll</tt>,
+ * <tt>equals</tt>, and <tt>toArray</tt> are <em>not</em> guaranteed
+ * to be performed atomically. For example, an iterator operating
+ * concurrently with an <tt>addAll</tt> operation might view only some
+ * of the added elements.
  *
  * <p>This class and its iterators implement all of the
  * <em>optional</em> methods of the {@link Set} and {@link Iterator}
--- a/jdk/src/share/classes/java/util/concurrent/LinkedTransferQueue.java	Fri Apr 22 11:03:39 2011 +0100
+++ b/jdk/src/share/classes/java/util/concurrent/LinkedTransferQueue.java	Fri Apr 22 16:33:23 2011 +0100
@@ -51,10 +51,17 @@
  * producer.  The <em>tail</em> of the queue is that element that has
  * been on the queue the shortest time for some producer.
  *
- * <p>Beware that, unlike in most collections, the {@code size}
- * method is <em>NOT</em> a constant-time operation. Because of the
+ * <p>Beware that, unlike in most collections, the {@code size} method
+ * is <em>NOT</em> a constant-time operation. Because of the
  * asynchronous nature of these queues, determining the current number
- * of elements requires a traversal of the elements.
+ * of elements requires a traversal of the elements, and so may report
+ * inaccurate results if this collection is modified during traversal.
+ * Additionally, the bulk operations {@code addAll},
+ * {@code removeAll}, {@code retainAll}, {@code containsAll},
+ * {@code equals}, and {@code toArray} are <em>not</em> guaranteed
+ * to be performed atomically. For example, an iterator operating
+ * concurrently with an {@code addAll} operation might view only some
+ * of the added elements.
  *
  * <p>This class and its iterator implement all of the
  * <em>optional</em> methods of the {@link Collection} and {@link