Permalink
Browse files

MpscLinkedAtomicQueue API breakage

Motivation:
4e68fd2 introduced a new code generation utility. However this commit removed the public constructor for MpscLinkedAtomicQueue because MpscLinkedQueue has a static factory method and a protected constructor.

Modifications:
- Restore the public constructor in MpscLinkedAtomicQueue

Result:
Original API restored for MpscLinkedAtomicQueue.
  • Loading branch information...
Scottmitch committed Aug 23, 2017
1 parent 74d5273 commit 03ed26e269e6a8a7a1c508475d417d1d85dabed3
@@ -50,6 +50,7 @@
public final class JavaParsingAtomicLinkedQueueGenerator extends VoidVisitorAdapter<Void> {
private static final String GEN_DIRECTIVE_CLASS_CONTAINS_ORDERED_FIELD_ACCESSORS = "$gen:ordered-fields";
private static final String GEN_DIRECTIVE_METHOD_IGNORE = "$gen:ignore";
private static final String MPSC_LINKED_ATOMIC_QUEUE_NAME = "MpscLinkedAtomicQueue";
private static final String INDENT_LEVEL = " ";
private final String sourceFileName;
@@ -83,7 +84,7 @@ public void visit(ClassOrInterfaceDeclaration node, Void arg) {
replaceParentClassesForAtomics(node);
node.setName(translateQueueName(node.getNameAsString()));
if ("MpscLinkedAtomicQueue".equals(node.getNameAsString())) {
if (MPSC_LINKED_ATOMIC_QUEUE_NAME.equals(node.getNameAsString())) {
/*
* Special case for MPSC
*/
@@ -115,6 +116,11 @@ public void visit(ConstructorDeclaration n, Void arg) {
super.visit(n, arg);
// Update the ctor to match the class name
n.setName(translateQueueName(n.getNameAsString()));
if (MPSC_LINKED_ATOMIC_QUEUE_NAME.equals(n.getNameAsString())) {
// Special case for MPSC because the Unsafe variant has a static factory method and a protected constructor.
n.setModifier(Modifier.PROTECTED, false);
n.setModifier(Modifier.PUBLIC, true);
}
}
@Override
@@ -232,7 +232,7 @@ public boolean offerIfBelowThreshold(final E e, int threshold) {
* Lock free offer using a single CAS. As class name suggests access is permitted to many threads
* concurrently.
*
* @see java.util.Queue#offer
* @see java.util.Queue#offer
* @see org.jctools.queues.MessagePassingQueue#offer
*/
@Override
@@ -44,7 +44,7 @@
*/
public final class MpscLinkedAtomicQueue<E> extends BaseLinkedAtomicQueue<E> {
protected MpscLinkedAtomicQueue() {
public MpscLinkedAtomicQueue() {
LinkedQueueAtomicNode<E> node = newNode();
spConsumerNode(node);
xchgProducerNode(node);

0 comments on commit 03ed26e

Please sign in to comment.