commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r762415 - in /commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl: GenericKeyedObjectPool.java GenericObjectPool.java
Date Mon, 06 Apr 2009 17:00:20 GMT
Author: markt
Date: Mon Apr  6 17:00:20 2009
New Revision: 762415

URL: http://svn.apache.org/viewvc?rev=762415&view=rev
Log:
Rename prior to using when fixing POOL-125

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=762415&r1=762414&r2=762415&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Mon Apr  6 17:00:20 2009
@@ -961,14 +961,14 @@
                     // if there is a totalMaxActive and we are at the limit then
                     // we have to make room
                     if ((_maxTotal > 0)
-                            && (_totalActive + _totalIdle + _totalCreatingIdle >=
_maxTotal)) {
+                            && (_totalActive + _totalIdle + _totalInternalProcessing
>= _maxTotal)) {
                         clearOldest();
                     }
     
                     // check if we can create one
                     // (note we know that the num sleeping is 0, else we wouldn't be here)
-                    if ((_maxActive < 0 || pool.activeCount + pool.creatingIdleCount <
_maxActive) &&
-                        (_maxTotal < 0 || _totalActive + _totalIdle + _totalCreatingIdle
< _maxTotal)) {
+                    if ((_maxActive < 0 || pool.activeCount + pool.internalProcessingCount
< _maxActive) &&
+                        (_maxTotal < 0 || _totalActive + _totalIdle + _totalInternalProcessing
< _maxTotal)) {
                         Object obj = _factory.makeObject(key);
                         pair = new ObjectTimestampPair(obj);
                         newlyCreated = true;
@@ -1625,7 +1625,7 @@
                 addObject(key);
             } finally {
                 synchronized (this) {
-                    pool.decrementCreatingIdleCount();
+                    pool.decrementInternalProcessingCount();
                     notifyAll();
                 }
             }
@@ -1678,32 +1678,35 @@
      * <p>
      * This method has been left public so derived classes can override
      * the way the defecit is calculated. ie... Increase/decrease the pool
-     * size at certain times of day to accomodate for usage patterns.
+     * size at certain times of day to accommodate for usage patterns.
      *
      * @param key - The key of the pool to calculate the number of
      *              objects to be re-created
+     * @param incrementInternal - Should the count of objects currently under
+     *                            some form of internal processing be
+     *                            incremented?
      * @return The number of objects to be created
      */
     private synchronized int calculateDefecit(ObjectQueue pool,
-            boolean incrementCreate) {
+            boolean incrementInternal) {
         int objectDefecit = 0;
 
         //Calculate no of objects needed to be created, in order to have
         //the number of pooled objects < maxActive();
         objectDefecit = getMinIdle() - pool.queue.size();
         if (getMaxActive() > 0) {
-            int growLimit = Math.max(0, getMaxActive() - pool.activeCount - pool.queue.size()
- pool.creatingIdleCount);
+            int growLimit = Math.max(0, getMaxActive() - pool.activeCount - pool.queue.size()
- pool.internalProcessingCount);
             objectDefecit = Math.min(objectDefecit, growLimit);
         }
 
         // Take the maxTotal limit into account
         if (getMaxTotal() > 0) {
-            int growLimit = Math.max(0, getMaxTotal() - getNumActive() - getNumIdle() - _totalCreatingIdle);
+            int growLimit = Math.max(0, getMaxTotal() - getNumActive() - getNumIdle() - _totalInternalProcessing);
             objectDefecit = Math.min(objectDefecit, growLimit);
         }
 
-        if (incrementCreate && objectDefecit > 0) {
-            pool.incrementCreatingIdleCount();
+        if (incrementInternal && objectDefecit > 0) {
+            pool.incrementInternalProcessingCount();
         }
         return objectDefecit;
     }
@@ -1716,7 +1719,7 @@
     private class ObjectQueue {
         private int activeCount = 0;
         private final CursorableLinkedList queue = new CursorableLinkedList();
-        private int creatingIdleCount = 0;
+        private int internalProcessingCount = 0;
 
         void incrementActiveCount() {
             _totalActive++;
@@ -1730,14 +1733,14 @@
             }
         }
 
-        void incrementCreatingIdleCount() {
-            _totalCreatingIdle++;
-            creatingIdleCount++;
+        void incrementInternalProcessingCount() {
+            _totalInternalProcessing++;
+            internalProcessingCount++;
         }
 
-        void decrementCreatingIdleCount() {
-            _totalCreatingIdle--;
-            creatingIdleCount--;
+        void decrementInternalProcessingCount() {
+            _totalInternalProcessing--;
+            internalProcessingCount--;
         }
 }
     
@@ -2017,10 +2020,11 @@
     private int _totalIdle = 0;
 
     /**
-     * The total number of idle objects that are in the process of being created
-     * but have not yet been added to the pool.
+     * The number of objects subject to some form of internal processing
+     * (usually creation or destruction) that should be included in the total
+     * number of objects but are neither active nor idle.
      */
-    private int _totalCreatingIdle = 0;
+    private int _totalInternalProcessing = 0;
 
     /** My {@link KeyedPoolableObjectFactory}. */
     private KeyedPoolableObjectFactory _factory = null;

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=762415&r1=762414&r2=762415&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Mon Apr  6 17:00:20 2009
@@ -933,7 +933,7 @@
                 if(null == pair) {
                     // check if we can create one
                     // (note we know that the num sleeping is 0, else we wouldn't be here)
-                    if(_maxActive < 0 || (_numActive + _numCreatingIdle) < _maxActive)
{
+                    if(_maxActive < 0 || (_numActive + _numInternalProcessing) < _maxActive)
{
                         // allow new object to be created
                     } else {
                         // the pool is exhausted
@@ -1262,22 +1262,22 @@
                 addObject();
             } finally {
                 synchronized (this) {
-                    _numCreatingIdle--;
+                    _numInternalProcessing--;
                     notifyAll();
                 }
             }
         }
     }
 
-    private synchronized int calculateDeficit(boolean incrementCreate) {
+    private synchronized int calculateDeficit(boolean incrementInternal) {
         int objectDeficit = getMinIdle() - getNumIdle();
         if (_maxActive > 0) {
             int growLimit = Math.max(0,
-                    getMaxActive() - getNumActive() - getNumIdle() - _numCreatingIdle);
+                    getMaxActive() - getNumActive() - getNumIdle() - _numInternalProcessing);
             objectDeficit = Math.min(objectDeficit, growLimit);
         }
-        if (incrementCreate && objectDeficit >0) {
-            _numCreatingIdle++;
+        if (incrementInternal && objectDeficit >0) {
+            _numInternalProcessing++;
         }
         return objectDeficit;
     }
@@ -1603,8 +1603,9 @@
     private Evictor _evictor = null;
 
     /**
-     * The number of idle objects that are in the process of being created but
-     * have not yet been added to the pool.
+     * The number of objects subject to some form of internal processing
+     * (usually creation or destruction) that should be included in the total
+     * number of objects but are neither active nor idle.
      */
-    private int _numCreatingIdle = 0;
+    private int _numInternalProcessing = 0;
 }



Mime
View raw message