You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by no...@apache.org on 2010/12/02 23:11:19 UTC
svn commit: r1041609 -
/incubator/aries/trunk/util/src/main/java/org/apache/aries/util/SingleServiceTracker.java
Author: not
Date: Thu Dec 2 22:11:19 2010
New Revision: 1041609
URL: http://svn.apache.org/viewvc?rev=1041609&view=rev
Log:
Add some comments around the locking.
Modified:
incubator/aries/trunk/util/src/main/java/org/apache/aries/util/SingleServiceTracker.java
Modified: incubator/aries/trunk/util/src/main/java/org/apache/aries/util/SingleServiceTracker.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/util/src/main/java/org/apache/aries/util/SingleServiceTracker.java?rev=1041609&r1=1041608&r2=1041609&view=diff
==============================================================================
--- incubator/aries/trunk/util/src/main/java/org/apache/aries/util/SingleServiceTracker.java (original)
+++ incubator/aries/trunk/util/src/main/java/org/apache/aries/util/SingleServiceTracker.java Thu Dec 2 22:11:19 2010
@@ -115,10 +115,13 @@ public final class SingleServiceTracker<
// Make sure we don't try to get a lock on null
Object lock;
+ // we have to choose our lock.
if (newRef != null) lock = newRef;
else if (deadRef != null) lock = deadRef;
else lock = this;
+ // This lock is here to ensure that no two threads can set the ref and service
+ // at the same time.
synchronized (lock) {
if (open.get()) {
result = this.ref.compareAndSet(deadRef, newRef);