< prev index next >
src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2020-12
Reviewed-by: martin
@@ -85,11 +85,11 @@
* {@code new FIFOEntry(anEntry)} instead of a plain entry object.
*
* <pre> {@code
* class FIFOEntry<E extends Comparable<? super E>>
* implements Comparable<FIFOEntry<E>> {
- * static final AtomicLong seq = new AtomicLong(0);
+ * static final AtomicLong seq = new AtomicLong();
* final long seqNum;
* final E entry;
* public FIFOEntry(E entry) {
* seqNum = seq.getAndIncrement();
* this.entry = entry;
@@ -224,11 +224,11 @@
}
/**
* Creates a {@code PriorityBlockingQueue} containing the elements
* in the specified collection. If the specified collection is a
- * {@link SortedSet} or a {@link PriorityQueue}, this
+ * {@link SortedSet} or a {@link PriorityBlockingQueue}, this
* priority queue will be ordered according to the same ordering.
* Otherwise, this priority queue will be ordered according to the
* {@linkplain Comparable natural ordering} of its elements.
*
* @param c the collection whose elements are to be placed
@@ -288,11 +288,13 @@
lock.unlock(); // must release and then re-acquire main lock
Object[] newArray = null;
if (allocationSpinLock == 0 &&
ALLOCATIONSPINLOCK.compareAndSet(this, 0, 1)) {
try {
- int growth = oldCap < 64 ? oldCap + 2 : oldCap >> 1;
+ int growth = (oldCap < 64)
+ ? (oldCap + 2) // grow faster if small
+ : (oldCap >> 1);
int newCap = ArraysSupport.newLength(oldCap, 1, growth);
if (queue == array)
newArray = new Object[newCap];
} finally {
allocationSpinLock = 0;
< prev index next >