You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2014/10/05 19:46:43 UTC

svn commit: r1629515 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java

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;
-
         }
     }
 }