svn commit: r929832 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r929832 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java

doogie-3
Author: doogie
Date: Thu Apr  1 04:43:12 2010
New Revision: 929832

URL: http://svn.apache.org/viewvc?rev=929832&view=rev
Log:
Remove helper method, incrementCounter, and just call incrementAndGet on
all the atomics.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=929832&r1=929831&r2=929832&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Thu Apr  1 04:43:12 2010
@@ -273,19 +273,19 @@ public class UtilCache<K, V> implements
     protected CacheLine<V> getInternal(Object key, boolean countGet) {
         CacheLine<V> line = getInternalNoCheck(key);
         if (line == null) {
-            if (countGet) incrementCounter(missCountNotFound);
+            if (countGet) missCountNotFound.incrementAndGet();
         } else if (line.isInvalid()) {
             removeInternal(key, false);
-            if (countGet) incrementCounter(missCountSoftRef);
+            if (countGet) missCountSoftRef.incrementAndGet();
             line = null;
         } else if (line.hasExpired()) {
             // note that print.info in debug.properties cannot be checked through UtilProperties here, it would cause infinite recursion...
             // if (Debug.infoOn()) Debug.logInfo("Element has expired with key " + key, module);
             removeInternal(key, false);
-            if (countGet) incrementCounter(missCountExpired);
+            if (countGet) missCountExpired.incrementAndGet();
             line = null;
         } else {
-            if (countGet) incrementCounter(hitCount);
+            if (countGet) hitCount.incrementAndGet();
         }
         return line;
     }
@@ -330,10 +330,10 @@ public class UtilCache<K, V> implements
         CacheLine<V> line = cacheLineTable.remove(key);
         if (line != null) {
             noteRemoval((K) key, line.getValue());
-            if (countRemove) incrementCounter(removeHitCount);
+            if (countRemove) removeHitCount.incrementAndGet();
             return line.getValue();
         } else {
-            if (countRemove) incrementCounter(removeMissCount);
+            if (countRemove) removeMissCount.incrementAndGet();
             return null;
         }
     }
@@ -369,13 +369,6 @@ public class UtilCache<K, V> implements
         return this.name;
     }
 
-    private static final void incrementCounter(AtomicLong stat) {
-        long currentValue;
-        do {
-            currentValue = stat.get();
-        } while (!stat.weakCompareAndSet(currentValue, currentValue + 1));
-    }
-
     /** Returns the number of successful hits on the cache
      * @return The number of successful cache hits
      */