commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1629515 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
Date Sun, 05 Oct 2014 17:46:43 GMT
Author: psteitz
Date: Sun Oct  5 17:46:43 2014
New Revision: 1629515

URL: http://svn.apache.org/r1629515
Log:
Added javadoc for StatsStore.

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java?rev=1629515&r1=1629514&r2=1629515&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
Sun Oct  5 17:46:43 2014
@@ -1044,12 +1044,21 @@ public abstract class BaseGenericObjectP
         }
     }
 
+    /**
+     * Maintains a cache of values for a single metric and reports
+     * statistics on the cached values.
+     */
     private class StatsStore {
 
         private final AtomicLong values[];
         private final int size;
         private int index;
 
+        /**
+         * Create a StatsStore with the given cache size.
+         *
+         * @param size number of values to maintain in the cache.
+         */
         public StatsStore(int size) {
             this.size = size;
             values = new AtomicLong[size];
@@ -1058,6 +1067,12 @@ public abstract class BaseGenericObjectP
             }
         }
 
+        /**
+         * Adds a value to the cache.  If the cache is full, one of the
+         * existing values is replaced by the new value.
+         *
+         * @param value new value to add to the cache.
+         */
         public synchronized void add(long value) {
             values[index].set(value);
             index++;
@@ -1066,6 +1081,11 @@ public abstract class BaseGenericObjectP
             }
         }
 
+        /**
+         * Returns the mean of the cached values.
+         *
+         * @return the mean of the cache, truncated to long
+         */
         public long getMean() {
             double result = 0;
             int counter = 0;
@@ -1078,7 +1098,6 @@ public abstract class BaseGenericObjectP
                 }
             }
             return (long) result;
-
         }
     }
 }



Mime
View raw message