8193300: Miscellaneous changes imported from jsr166 CVS 2018-01

Reviewed-by: martin
This commit is contained in:
Doug Lea 2018-01-16 18:28:39 -08:00
parent c19d18871c
commit d771fc3a6b
149 changed files with 872 additions and 571 deletions

View file

@ -1353,17 +1353,16 @@ public class LinkedBlockingDeque<E>
@SuppressWarnings("unchecked")
private boolean bulkRemove(Predicate<? super E> filter) {
boolean removed = false;
Node<E> p = null;
final ReentrantLock lock = this.lock;
Node<E> p = null;
Node<E>[] nodes = null;
int n, len = 0;
do {
// 1. Extract batch of up to 64 elements while holding the lock.
long deathRow = 0; // "bitset" of size 64
lock.lock();
try {
if (nodes == null) {
if (p == null) p = first;
if (nodes == null) { // first batch; initialize
p = first;
for (Node<E> q = p; q != null; q = succ(q))
if (q.item != null && ++len == 64)
break;
@ -1376,6 +1375,7 @@ public class LinkedBlockingDeque<E>
}
// 2. Run the filter on the elements while lock is free.
long deathRow = 0L; // "bitset" of size 64
for (int i = 0; i < n; i++) {
final E e;
if ((e = nodes[i].item) != null && filter.test(e))
@ -1393,6 +1393,7 @@ public class LinkedBlockingDeque<E>
unlink(q);
removed = true;
}
nodes[i] = null; // help GC
}
} finally {
lock.unlock();