Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB6D318475 for ; Tue, 29 Dec 2015 10:16:58 +0000 (UTC) Received: (qmail 93848 invoked by uid 500); 29 Dec 2015 10:16:58 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 93811 invoked by uid 500); 29 Dec 2015 10:16:58 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 93802 invoked by uid 99); 29 Dec 2015 10:16:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Dec 2015 10:16:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AF421E054A; Tue, 29 Dec 2015 10:16:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: IGNITE-2314: Padding. Date: Tue, 29 Dec 2015 10:16:58 +0000 (UTC) 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 Authored: Tue Dec 29 13:17:54 2015 +0300 Committer: vozerov-gridgain 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 * * Non-intrusive MPSC node-based queue. */ -public class MPSCConcurrentLinkedQueue -{ - /** Tail field updater. */ - private static final AtomicReferenceFieldUpdater TAIL_UPD = - AtomicReferenceFieldUpdater.newUpdater(MPSCConcurrentLinkedQueue.class, Node.class, "tail"); +public class MPSCConcurrentLinkedQueue 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 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 @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 else return null; } - - /** - * Node with data. - */ - private static class Node - { - /** Next field updater. */ - public static final AtomicReferenceFieldUpdater 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 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 TAIL_UPD = + AtomicReferenceFieldUpdater.newUpdater(MPSCConcurrentLinkedQueueTail.class, MPSCConcurrentLinkedQueueNode.class, "tail"); + + /** Tail. */ + @SuppressWarnings({"UnusedDeclaration", "FieldCanBeLocal"}) + protected volatile MPSCConcurrentLinkedQueueNode tail; +}