[jbosscache-commits] JBoss Cache SVN: r5386 - core/trunk/src/main/java/org/jboss/cache/lock.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Mar 5 07:36:32 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-03-05 07:36:31 -0500 (Wed, 05 Mar 2008)
New Revision: 5386

Modified:
   core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
Log:
Added comment on constructor and removed creation of an unmodifiable collection when returning the readOwners collection.

Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java	2008-03-04 20:37:51 UTC (rev 5385)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockMap.java	2008-03-05 12:36:31 UTC (rev 5386)
@@ -8,7 +8,7 @@
 
 import org.jboss.cache.util.concurrent.ConcurrentHashSet;
 
-import java.util.*;
+import java.util.Collection;
 
 /**
  * Provide lock ownership mapping.
@@ -25,7 +25,6 @@
    private Object writeOwner_ = null;
 
 
-
    // This is more efficient (lower CPU utilisation and better concurrency) than a CopyOnWriteArraySet or ConcurrentHashSet.
    // for some reason this barfs with concurrent mod exceptions.  Need to see why.
    private final Collection<Object> readOwners;
@@ -37,6 +36,11 @@
       this(new ConcurrentHashSet<Object>());
    }
 
+   /**
+    * This constructor is made available for testing with different collection types for the readOwners collection.
+    *
+    * @param readOwners
+    */
    public LockMap(Collection<Object> readOwners)
    {
       this.readOwners = readOwners;
@@ -128,7 +132,9 @@
     */
    public Collection<Object> readerOwners()
    {
-      return Collections.unmodifiableCollection(readOwners);
+      // not necessary if the collection is a CHS.  Saves on overhead.
+//      return Collections.unmodifiableCollection(readOwners);
+      return readOwners;
    }
 
    public void releaseReaderOwners(LockStrategy lock)




More information about the jbosscache-commits mailing list