activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r633570 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
Date Tue, 04 Mar 2008 17:52:19 GMT
Author: chirino
Date: Tue Mar  4 09:52:14 2008
New Revision: 633570

URL: http://svn.apache.org/viewvc?rev=633570&view=rev
Log:
Reduce contention by using an Atomic Reference.

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java?rev=633570&r1=633569&r2=633570&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java
Tue Mar  4 09:52:14 2008
@@ -19,6 +19,8 @@
 import java.net.URI;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
 import org.apache.activemq.broker.region.Destination;
 import org.apache.activemq.broker.region.MessageReference;
 import org.apache.activemq.broker.region.Subscription;
@@ -49,30 +51,25 @@
  */
 public class MutableBrokerFilter implements Broker {
 
-    private Broker next;
-    private final Object mutext = new Object();
+    private AtomicReference<Broker> next = new AtomicReference<Broker>();
 
     public MutableBrokerFilter(Broker next) {
-        this.next = next;
+        this.next.set(next);
     }
 
     public Broker getAdaptor(Class type) {
         if (type.isInstance(this)) {
             return this;
         }
-        return next.getAdaptor(type);
+        return next.get().getAdaptor(type);
     }
 
     public Broker getNext() {
-        synchronized (mutext) {
-            return next;
-        }
+        return next.get();
     }
 
     public void setNext(Broker next) {
-        synchronized (mutext) {
-            this.next = next;
-        }
+    	this.next.set(next);
     }
 
     public Map<ActiveMQDestination, Destination> getDestinationMap() {



Mime
View raw message