ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-2314: Padding.
Date Tue, 29 Dec 2015 10:16:58 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2314 4f55c84f0 -> 3f3dcf439


IGNITE-2314: Padding.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3f3dcf43
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3f3dcf43
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3f3dcf43

Branch: refs/heads/ignite-2314
Commit: 3f3dcf439bce29e1ad89d5c032061b31d781ec4c
Parents: 4f55c84
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Dec 29 13:17:54 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Dec 29 13:17:54 2015 +0300

----------------------------------------------------------------------
 .../util/MPSCConcurrentLinkedQueue.java         | 66 +++-------------
 .../util/MPSCConcurrentLinkedQueueNode.java     | 83 ++++++++++++++++++++
 .../util/MPSCConcurrentLinkedQueuePadding.java  | 26 ++++++
 .../util/MPSCConcurrentLinkedQueueTail.java     | 33 ++++++++
 4 files changed, 152 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3f3dcf43/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueue.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueue.java
index 1990732..4d4fe3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueue.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueue.java
@@ -17,32 +17,23 @@
 
 package org.apache.ignite.internal.util;
 
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-
 /**
  * MP-SC concurrent linked queue implementation based on Dmitry Vyukov's
  * <a href="http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue">
  *     Non-intrusive MPSC node-based queue</a>.
  */
-public class MPSCConcurrentLinkedQueue<E>
-{
-    /** Tail field updater. */
-    private static final AtomicReferenceFieldUpdater<MPSCConcurrentLinkedQueue, Node>
TAIL_UPD =
-        AtomicReferenceFieldUpdater.newUpdater(MPSCConcurrentLinkedQueue.class, Node.class,
"tail");
 
+public class MPSCConcurrentLinkedQueue<E> extends MPSCConcurrentLinkedQueuePadding
+{
     /** Head. */
-    private Node head;
-
-    /** Tail. */
-    @SuppressWarnings({"UnusedDeclaration", "FieldCanBeLocal"})
-    private volatile Node tail;
+    private MPSCConcurrentLinkedQueueNode head;
 
     /**
      * Constructor.
      */
     public MPSCConcurrentLinkedQueue()
     {
-        head = new Node(null);
+        head = new MPSCConcurrentLinkedQueueNode(null);
 
         tail = head;
     }
@@ -57,11 +48,11 @@ public class MPSCConcurrentLinkedQueue<E>
         if (e == null)
             throw new IllegalArgumentException("Null are not allowed.");
 
-        Node newTail = new Node(e);
+        MPSCConcurrentLinkedQueueNode newTail = new MPSCConcurrentLinkedQueueNode(e);
 
-        Node prevTail = TAIL_UPD.getAndSet(this, newTail);
+        MPSCConcurrentLinkedQueueNode prevTail = TAIL_UPD.getAndSet(this, newTail);
 
-        prevTail.setNext(newTail);
+        prevTail.next(newTail);
     }
 
     /**
@@ -72,13 +63,13 @@ public class MPSCConcurrentLinkedQueue<E>
     @SuppressWarnings("unchecked")
     public E poll()
     {
-        final Node node = head.next;
+        final MPSCConcurrentLinkedQueueNode node = head.next();
 
         if (node != null)
         {
-            Object val = node.val;
+            Object val = node.value();
 
-            node.val = null;
+            node.value(null);
 
             head = node;
 
@@ -87,41 +78,4 @@ public class MPSCConcurrentLinkedQueue<E>
         else
             return null;
     }
-
-    /**
-     * Node with data.
-     */
-    private static class Node
-    {
-        /** Next field updater. */
-        public static final AtomicReferenceFieldUpdater<Node, Node> NODE_UPD =
-            AtomicReferenceFieldUpdater.newUpdater(Node.class, Node.class, "next");
-
-        /** Value. */
-        private Object val;
-
-        /** Next node. */
-        @SuppressWarnings("UnusedDeclaration")
-        private volatile Node next;
-
-        /**
-         * Constructor.
-         *
-         * @param val Value.
-         */
-        private Node(Object val)
-        {
-            this.val = val;
-        }
-
-        /**
-         * Set next node.
-         *
-         * @param next Next node.
-         */
-        void setNext(Node next)
-        {
-            NODE_UPD.lazySet(this, next);
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f3dcf43/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueNode.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueNode.java
new file mode 100644
index 0000000..c46cc51
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueNode.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+
+/**
+ * Node for {@link MPSCConcurrentLinkedQueue}.
+ */
+public class MPSCConcurrentLinkedQueueNode {
+    /** Next field updater. */
+    private static final AtomicReferenceFieldUpdater<MPSCConcurrentLinkedQueueNode, MPSCConcurrentLinkedQueueNode>
NODE_UPD =
+        AtomicReferenceFieldUpdater.newUpdater(MPSCConcurrentLinkedQueueNode.class, MPSCConcurrentLinkedQueueNode.class,
"next");
+
+    /** Value. */
+    private Object val;
+
+    /** Next node. */
+    @SuppressWarnings("UnusedDeclaration")
+    private volatile MPSCConcurrentLinkedQueueNode next;
+
+    /**
+     * Constructor.
+     *
+     * @param val Value.
+     */
+    MPSCConcurrentLinkedQueueNode(Object val)
+    {
+        this.val = val;
+    }
+
+    /**
+     * Get value.
+     *
+     * @return Value.
+     */
+    Object value() {
+        return val;
+    }
+
+    /**
+     * Set value.
+     *
+     * @param val Value.
+     */
+    void value(Object val) {
+        this.val = val;
+    }
+
+    /**
+     * Get next node.
+     *
+     * @return Next node.
+     */
+    MPSCConcurrentLinkedQueueNode next() {
+        return next;
+    }
+
+    /**
+     * Set next node.
+     *
+     * @param next Next node.
+     */
+    void next(MPSCConcurrentLinkedQueueNode next)
+    {
+        NODE_UPD.lazySet(this, next);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f3dcf43/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueuePadding.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueuePadding.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueuePadding.java
new file mode 100644
index 0000000..7bd0245
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueuePadding.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+/**
+ * Padding for {@link MPSCConcurrentLinkedQueue}.
+ */
+public class MPSCConcurrentLinkedQueuePadding extends MPSCConcurrentLinkedQueueTail {
+    /** Padding. */
+    private long p0, p1, p2, p3, p4, p5, p6, p7;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f3dcf43/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueTail.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueTail.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueTail.java
new file mode 100644
index 0000000..21e394a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/MPSCConcurrentLinkedQueueTail.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+
+/**
+ * Tail of {@link MPSCConcurrentLinkedQueue}.
+ */
+public class MPSCConcurrentLinkedQueueTail {
+    /** Tail field updater. */
+    protected static final AtomicReferenceFieldUpdater<MPSCConcurrentLinkedQueueTail,
MPSCConcurrentLinkedQueueNode> TAIL_UPD =
+        AtomicReferenceFieldUpdater.newUpdater(MPSCConcurrentLinkedQueueTail.class, MPSCConcurrentLinkedQueueNode.class,
"tail");
+
+    /** Tail. */
+    @SuppressWarnings({"UnusedDeclaration", "FieldCanBeLocal"})
+    protected volatile MPSCConcurrentLinkedQueueNode tail;
+}


Mime
View raw message