src/share/classes/java/util/concurrent/LinkedTransferQueue.java

Print this page

        

@@ -328,12 +328,12 @@
      *    heavily contended queues. And so long as it is relatively
      *    brief and "quiet", spinning does not much impact performance
      *    of less-contended queues.  During spins threads check their
      *    interrupt status and generate a thread-local random number
      *    to decide to occasionally perform a Thread.yield. While
-     *    yield has underdefined specs, we assume that might it help,
-     *    and will not hurt in limiting impact of spinning on busy
+     *    yield has underdefined specs, we assume that it might help,
+     *    and will not hurt, in limiting impact of spinning on busy
      *    systems.  We also use smaller (1/2) spins for nodes that are
      *    not known to be front but whose predecessors have not
      *    blocked -- these "chained" spins avoid artifacts of
      *    front-of-queue rules which otherwise lead to alternating
      *    nodes spinning vs blocking. Further, front threads that

@@ -540,11 +540,11 @@
         private static final long nextOffset;
         private static final long waiterOffset;
         static {
             try {
                 UNSAFE = sun.misc.Unsafe.getUnsafe();
-                Class k = Node.class;
+                Class<?> k = Node.class;
                 itemOffset = UNSAFE.objectFieldOffset
                     (k.getDeclaredField("item"));
                 nextOffset = UNSAFE.objectFieldOffset
                     (k.getDeclaredField("next"));
                 waiterOffset = UNSAFE.objectFieldOffset

@@ -625,11 +625,11 @@
                             if ((h = head)   == null ||
                                 (q = h.next) == null || !q.isMatched())
                                 break;        // unless slack < 2
                         }
                         LockSupport.unpark(p.waiter);
-                        return this.<E>cast(item);
+                        return LinkedTransferQueue.<E>cast(item);
                     }
                 }
                 Node n = p.next;
                 p = (p != n) ? n : (h = head); // Use head if p offlist
             }

@@ -703,11 +703,11 @@
         for (;;) {
             Object item = s.item;
             if (item != e) {                  // matched
                 // assert item != s;
                 s.forgetContents();           // avoid garbage
-                return this.<E>cast(item);
+                return LinkedTransferQueue.<E>cast(item);
             }
             if ((w.isInterrupted() || (timed && nanos <= 0)) &&
                     s.casItem(e, s)) {        // cancel
                 unsplice(pred, s);
                 return e;

@@ -784,11 +784,11 @@
     private E firstDataItem() {
         for (Node p = head; p != null; p = succ(p)) {
             Object item = p.item;
             if (p.isData) {
                 if (item != null && item != p)
-                    return this.<E>cast(item);
+                    return LinkedTransferQueue.<E>cast(item);
             }
             else if (item == null)
                 return null;
         }
         return null;

@@ -1006,11 +1006,10 @@
             }
         }
         return false;
     }
 
-
     /**
      * Creates an initially empty {@code LinkedTransferQueue}.
      */
     public LinkedTransferQueue() {
     }

@@ -1043,11 +1042,12 @@
      * Inserts the specified element at the tail of this queue.
      * As the queue is unbounded, this method will never block or
      * return {@code false}.
      *
      * @return {@code true} (as specified by
-     *  {@link BlockingQueue#offer(Object,long,TimeUnit) BlockingQueue.offer})
+     *  {@link java.util.concurrent.BlockingQueue#offer(Object,long,TimeUnit)
+     *  BlockingQueue.offer})
      * @throws NullPointerException if the specified element is null
      */
     public boolean offer(E e, long timeout, TimeUnit unit) {
         xfer(e, true, ASYNC, 0);
         return true;

@@ -1160,12 +1160,11 @@
         if (c == null)
             throw new NullPointerException();
         if (c == this)
             throw new IllegalArgumentException();
         int n = 0;
-        E e;
-        while ( (e = poll()) != null) {
+        for (E e; (e = poll()) != null;) {
             c.add(e);
             ++n;
         }
         return n;
     }

@@ -1178,12 +1177,11 @@
         if (c == null)
             throw new NullPointerException();
         if (c == this)
             throw new IllegalArgumentException();
         int n = 0;
-        E e;
-        while (n < maxElements && (e = poll()) != null) {
+        for (E e; n < maxElements && (e = poll()) != null;) {
             c.add(e);
             ++n;
         }
         return n;
     }

@@ -1286,11 +1284,12 @@
     /**
      * Always returns {@code Integer.MAX_VALUE} because a
      * {@code LinkedTransferQueue} is not capacity constrained.
      *
      * @return {@code Integer.MAX_VALUE} (as specified by
-     *         {@link BlockingQueue#remainingCapacity()})
+     *         {@link java.util.concurrent.BlockingQueue#remainingCapacity()
+     *         BlockingQueue.remainingCapacity})
      */
     public int remainingCapacity() {
         return Integer.MAX_VALUE;
     }
 

@@ -1335,11 +1334,11 @@
     private static final long tailOffset;
     private static final long sweepVotesOffset;
     static {
         try {
             UNSAFE = sun.misc.Unsafe.getUnsafe();
-            Class k = LinkedTransferQueue.class;
+            Class<?> k = LinkedTransferQueue.class;
             headOffset = UNSAFE.objectFieldOffset
                 (k.getDeclaredField("head"));
             tailOffset = UNSAFE.objectFieldOffset
                 (k.getDeclaredField("tail"));
             sweepVotesOffset = UNSAFE.objectFieldOffset