提交 c79c53a2 编写于 作者: D dl

6981113: Add ConcurrentLinkedDeque

Summary: Extend techniques developed for ConcurrentLinkedQueue and LinkedTransferQueue to implement a non-blocking concurrent Deque with interior removes.
Reviewed-by: martin, dholmes, chegar
上级 bfeeb3b8
......@@ -272,6 +272,7 @@ JAVA_JAVA_java = \
java/util/concurrent/CancellationException.java \
java/util/concurrent/CompletionService.java \
java/util/concurrent/ConcurrentHashMap.java \
java/util/concurrent/ConcurrentLinkedDeque.java \
java/util/concurrent/ConcurrentLinkedQueue.java \
java/util/concurrent/ConcurrentMap.java \
java/util/concurrent/ConcurrentNavigableMap.java \
......
......@@ -173,6 +173,11 @@ public class BiggernYours {
new ConcurrentHashMap() {
public int size() {return randomize(super.size());}});
testCollections(
new ConcurrentLinkedDeque(),
new ConcurrentLinkedDeque() {
public int size() {return randomize(super.size());}});
testCollections(
new ConcurrentLinkedQueue(),
new ConcurrentLinkedQueue() {
......
......@@ -48,6 +48,7 @@ public class IteratorAtEnd {
testCollection(new PriorityQueue());
testCollection(new LinkedBlockingQueue());
testCollection(new ArrayBlockingQueue(100));
testCollection(new ConcurrentLinkedDeque());
testCollection(new ConcurrentLinkedQueue());
testCollection(new LinkedTransferQueue());
......
......@@ -75,6 +75,7 @@ public class MOAT {
testCollection(new ArrayBlockingQueue<Integer>(20));
testCollection(new LinkedBlockingQueue<Integer>(20));
testCollection(new LinkedBlockingDeque<Integer>(20));
testCollection(new ConcurrentLinkedDeque<Integer>());
testCollection(new ConcurrentLinkedQueue<Integer>());
testCollection(new LinkedTransferQueue<Integer>());
testCollection(new ConcurrentSkipListSet<Integer>());
......@@ -431,8 +432,9 @@ public class MOAT {
q.poll();
equal(q.size(), 4);
checkFunctionalInvariants(q);
if ((q instanceof LinkedBlockingQueue) ||
(q instanceof LinkedBlockingDeque) ||
if ((q instanceof LinkedBlockingQueue) ||
(q instanceof LinkedBlockingDeque) ||
(q instanceof ConcurrentLinkedDeque) ||
(q instanceof ConcurrentLinkedQueue)) {
testQueueIteratorRemove(q);
}
......
......@@ -235,6 +235,7 @@ public class RacingCollections {
new ArrayList<Queue<Integer>>(newConcurrentDeques());
list.add(new LinkedBlockingQueue<Integer>(10));
list.add(new LinkedTransferQueue<Integer>());
list.add(new ConcurrentLinkedQueue<Integer>());
return list;
}
......@@ -248,6 +249,7 @@ public class RacingCollections {
private static List<Deque<Integer>> newConcurrentDeques() {
List<Deque<Integer>> list = new ArrayList<Deque<Integer>>();
list.add(new LinkedBlockingDeque<Integer>(10));
list.add(new ConcurrentLinkedDeque<Integer>());
return list;
}
......
......@@ -129,6 +129,7 @@ public class ChorusLine {
deqs.add(new ArrayDeque<Integer>());
deqs.add(new LinkedList<Integer>());
deqs.add(new LinkedBlockingDeque<Integer>());
deqs.add(new ConcurrentLinkedDeque<Integer>());
equal(deqs);
......
......@@ -55,6 +55,7 @@ public class ConcurrentQueueLoops {
Collection<Queue<Integer>> concurrentQueues() {
List<Queue<Integer>> queues = new ArrayList<Queue<Integer>>();
queues.add(new ConcurrentLinkedDeque<Integer>());
queues.add(new ConcurrentLinkedQueue<Integer>());
queues.add(new ArrayBlockingQueue<Integer>(items, false));
//queues.add(new ArrayBlockingQueue<Integer>(count, true));
......@@ -105,7 +106,7 @@ public class ConcurrentQueueLoops {
final Queue<Integer> queue;
final CyclicBarrier barrier;
int items;
Stage (Queue<Integer> q, CyclicBarrier b, int items) {
Stage(Queue<Integer> q, CyclicBarrier b, int items) {
queue = q;
barrier = b;
this.items = items;
......
......@@ -40,6 +40,7 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -62,6 +63,7 @@ public class GCRetention {
Collection<Queue<Boolean>> queues() {
List<Queue<Boolean>> queues = new ArrayList<Queue<Boolean>>();
queues.add(new ConcurrentLinkedDeque<Boolean>());
queues.add(new ConcurrentLinkedQueue<Boolean>());
queues.add(new ArrayBlockingQueue<Boolean>(count, false));
queues.add(new ArrayBlockingQueue<Boolean>(count, true));
......
......@@ -48,6 +48,7 @@ public class IteratorWeakConsistency {
test(new LinkedBlockingQueue(20));
test(new LinkedBlockingDeque());
test(new LinkedBlockingDeque(20));
test(new ConcurrentLinkedDeque());
test(new ConcurrentLinkedQueue());
test(new LinkedTransferQueue());
// Other concurrent queues (e.g. ArrayBlockingQueue) do not
......
......@@ -55,6 +55,7 @@ public class OfferRemoveLoops {
testQueue(new LinkedBlockingDeque());
testQueue(new ArrayBlockingQueue(10));
testQueue(new PriorityBlockingQueue(10));
testQueue(new ConcurrentLinkedDeque());
testQueue(new ConcurrentLinkedQueue());
testQueue(new LinkedTransferQueue());
}
......
......@@ -41,6 +41,7 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
......@@ -62,6 +63,7 @@ public class RemovePollRace {
Collection<Queue<Boolean>> concurrentQueues() {
List<Queue<Boolean>> queues = new ArrayList<Queue<Boolean>>();
queues.add(new ConcurrentLinkedDeque<Boolean>());
queues.add(new ConcurrentLinkedQueue<Boolean>());
queues.add(new ArrayBlockingQueue<Boolean>(count, false));
queues.add(new ArrayBlockingQueue<Boolean>(count, true));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册