You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2018/06/08 17:09:56 UTC
qpid-jms git commit: QPIDJMS-390 Use an atomic int field updater in
ProviderFuture
Repository: qpid-jms
Updated Branches:
refs/heads/master 816773722 -> 615fb0848
QPIDJMS-390 Use an atomic int field updater in ProviderFuture
Avoid allocation of AtomicBoolean instances for each ProviderFuture
instance and instead use an Atomic field updater to reduce GC overhead
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/615fb084
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/615fb084
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/615fb084
Branch: refs/heads/master
Commit: 615fb084877c430c2d040427d78423ac8bab245b
Parents: 8167737
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Jun 8 13:09:43 2018 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Jun 8 13:09:43 2018 -0400
----------------------------------------------------------------------
.../org/apache/qpid/jms/provider/ProviderFuture.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/615fb084/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/ProviderFuture.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/ProviderFuture.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/ProviderFuture.java
index 61168d4..01b3c6e 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/ProviderFuture.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/ProviderFuture.java
@@ -19,7 +19,7 @@ package org.apache.qpid.jms.provider;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.apache.qpid.jms.util.IOExceptionSupport;
@@ -28,11 +28,16 @@ import org.apache.qpid.jms.util.IOExceptionSupport;
*/
public class ProviderFuture implements AsyncResult {
- private final AtomicBoolean completer = new AtomicBoolean();
+ private static final AtomicIntegerFieldUpdater<ProviderFuture> COMPLETE_UPDATER =
+ AtomicIntegerFieldUpdater.newUpdater(ProviderFuture.class, "complete");
+
private final CountDownLatch latch = new CountDownLatch(1);
private final ProviderSynchronization synchronization;
private volatile Throwable error;
+ @SuppressWarnings("unused")
+ private volatile int complete;
+
public ProviderFuture() {
this(null);
}
@@ -48,7 +53,7 @@ public class ProviderFuture implements AsyncResult {
@Override
public void onFailure(Throwable result) {
- if (completer.compareAndSet(false, true)) {
+ if (COMPLETE_UPDATER.compareAndSet(this, 0, 1)) {
error = result;
if (synchronization != null) {
synchronization.onPendingFailure(error);
@@ -59,7 +64,7 @@ public class ProviderFuture implements AsyncResult {
@Override
public void onSuccess() {
- if (completer.compareAndSet(false, true)) {
+ if (COMPLETE_UPDATER.compareAndSet(this, 0, 1)) {
if (synchronization != null) {
synchronization.onPendingSuccess();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org