-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add combining arena to single consumer queue (closes #2)
- Loading branch information
Showing
8 changed files
with
315 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,53 +22,32 @@ | |
import java.util.concurrent.LinkedBlockingQueue; | ||
import java.util.concurrent.LinkedTransferQueue; | ||
import java.util.concurrent.SynchronousQueue; | ||
import java.util.function.Supplier; | ||
|
||
import com.google.common.collect.Queues; | ||
|
||
/** | ||
* @author [email protected] (Ben Manes) | ||
*/ | ||
public enum QueueType { | ||
SingleConsumerQueue() { | ||
@Override public <E> Queue<E> create() { | ||
return new SingleConsumerQueue<E>(); | ||
} | ||
}, | ||
EliminationStack() { | ||
@Override public <E> Queue<E> create() { | ||
return new EliminationStack<E>().asLifoQueue(); | ||
} | ||
}, | ||
ConcurrentLinkedQueue() { | ||
@Override public <E> Queue<E> create() { | ||
return new ConcurrentLinkedQueue<E>(); | ||
} | ||
}, | ||
ArrayBlockingQueue() { | ||
@Override public <E> Queue<E> create() { | ||
return new ArrayBlockingQueue<E>(10000); | ||
} | ||
}, | ||
LinkedBlockingQueueBenchmark() { | ||
@Override public <E> Queue<E> create() { | ||
return new LinkedBlockingQueue<E>(); | ||
} | ||
}, | ||
LinkedTransferQueue() { | ||
@Override public <E> Queue<E> create() { | ||
return new LinkedTransferQueue<E>(); | ||
} | ||
}, | ||
SynchronousQueue() { | ||
@Override public <E> Queue<E> create() { | ||
return new SynchronousQueue<E>(); | ||
} | ||
}, | ||
SynchronizedArrayDeque() { | ||
@Override public <E> Queue<E> create() { | ||
return Queues.synchronizedDeque(new ArrayDeque<E>(10000)); | ||
} | ||
}; | ||
SingleConsumerQueue_optimistic(SingleConsumerQueue::optimistic), | ||
SingleConsumerQueue_linearizable(SingleConsumerQueue::linearizable), | ||
EliminationStack(() -> new EliminationStack<>().asLifoQueue()), | ||
ConcurrentLinkedQueue(ConcurrentLinkedQueue<Object>::new), | ||
ArrayBlockingQueue(() -> new ArrayBlockingQueue<>(10000)), | ||
LinkedBlockingQueueBenchmark(LinkedBlockingQueue<Object>::new), | ||
LinkedTransferQueue(LinkedTransferQueue<Object>::new), | ||
SynchronousQueue(SynchronousQueue<Object>::new), | ||
SynchronizedArrayDeque(() -> Queues.synchronizedDeque(new ArrayDeque<>(10000))); | ||
|
||
public abstract <E> Queue<E> create(); | ||
private final Supplier<Queue<Object>> factory; | ||
|
||
private QueueType(Supplier<Queue<Object>> factory) { | ||
this.factory = factory; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public <E> Queue<E> create() { | ||
return (Queue<E>) factory.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.