avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool AbstractPool.java DefaultPool.java SoftResourceLimitingPool.java
Date Fri, 21 Dec 2001 16:58:06 GMT
bloritsch    01/12/21 08:58:06

  Modified:    src/java/org/apache/avalon/excalibur/datasource
                        JdbcConnectionPool.java
               src/java/org/apache/avalon/excalibur/pool AbstractPool.java
                        DefaultPool.java SoftResourceLimitingPool.java
  Log:
   speed up pool implementation a little, fixed some compilation errors
  
  Revision  Changes    Path
  1.14      +5 -10     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/JdbcConnectionPool.java
  
  Index: JdbcConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/JdbcConnectionPool.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JdbcConnectionPool.java	2001/12/11 09:53:28	1.13
  +++ JdbcConnectionPool.java	2001/12/21 16:58:06	1.14
  @@ -21,7 +21,7 @@
    * thread to manage the number of SQL Connections.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.13 $ $Date: 2001/12/11 09:53:28 $
  + * @version CVS $Revision: 1.14 $ $Date: 2001/12/21 16:58:06 $
    * @since 4.0
    */
   public class JdbcConnectionPool
  @@ -85,13 +85,13 @@
                   try
                   {
                       curMillis = System.currentTimeMillis();
  -                    m_mutex.unlock();
  +                    m_mutex.release();
   
                       thread.wait( endTime - curMillis );
                   }
                   finally
                   {
  -                    m_mutex.lock();
  +                    m_mutex.acquire();
                   }
   
                   try
  @@ -143,17 +143,12 @@
               }
   
               try {
  -                m_mutex.lock();
  +                m_mutex.acquire();
                   if (m_active.contains(obj))
                   {
                       m_active.remove(obj);
                   }
   
  -                if (m_ready.contains(obj))
  -                {
  -                    m_ready.remove(obj);
  -                }
  -
                   this.removePoolable(obj);
   
                   obj = (JdbcConnection) this.newPoolable();
  @@ -170,7 +165,7 @@
               }
               finally
               {
  -                m_mutex.unlock();
  +                m_mutex.release();
               }
           }
   
  
  
  
  1.7       +11 -8     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool/AbstractPool.java
  
  Index: AbstractPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool/AbstractPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractPool.java	2001/12/11 09:53:31	1.6
  +++ AbstractPool.java	2001/12/21 16:58:06	1.7
  @@ -7,9 +7,12 @@
    */
   package org.apache.avalon.excalibur.pool;
   
  -import java.util.List;
   import java.util.ArrayList;
  -import org.apache.avalon.excalibur.concurrent.Lock;
  +import java.util.List;
  +
  +import org.apache.avalon.excalibur.collections.Buffer;
  +import org.apache.avalon.excalibur.collections.VariableSizeBuffer;
  +import org.apache.avalon.excalibur.concurrent.Mutex;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.Loggable;
  @@ -20,7 +23,7 @@
    * This is an <code>Pool</code> that caches Poolable objects for reuse.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/12/11 09:53:31 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/12/21 16:58:06 $
    * @since 4.0
    */
   public abstract class AbstractPool
  @@ -30,8 +33,8 @@
       public static final int        DEFAULT_POOL_SIZE  = 8;
       protected final ObjectFactory  m_factory;
       protected List                 m_active           = new ArrayList();
  -    protected List                 m_ready            = new ArrayList();
  -    protected Lock                 m_mutex            = new Lock();
  +    protected Buffer               m_ready            = new VariableSizeBuffer();
  +    protected Mutex                m_mutex            = new Mutex();
       protected boolean              m_initialized      = false;
       protected int                  m_min;
   
  @@ -57,7 +60,7 @@
       protected void initialize()
           throws Exception
       {
  -        m_mutex.lock();
  +        m_mutex.acquire();
   
           for( int i = 0; i < AbstractPool.DEFAULT_POOL_SIZE; i++ )
           {
  @@ -66,7 +69,7 @@
   
           m_initialized = true;
   
  -        m_mutex.unlock();
  +        m_mutex.release();
       }
   
   
  @@ -139,7 +142,7 @@
               {
                   try
                   {
  -                    this.removePoolable( (Poolable) m_ready.remove( 0 ) );
  +                    this.removePoolable( (Poolable) m_ready.remove() );
                   }
                   catch( final Exception e )
                   {
  
  
  
  1.9       +10 -10    jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool/DefaultPool.java
  
  Index: DefaultPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool/DefaultPool.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultPool.java	2001/12/11 16:14:31	1.8
  +++ DefaultPool.java	2001/12/21 16:58:06	1.9
  @@ -16,7 +16,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version CVS $Revision: 1.8 $ $Date: 2001/12/11 16:14:31 $
  + * @version CVS $Revision: 1.9 $ $Date: 2001/12/21 16:58:06 $
    * @since 4.0
    */
   public class DefaultPool
  @@ -116,7 +116,7 @@
   
           try
           {
  -            m_mutex.lock();
  +            m_mutex.acquire();
   
               if( m_ready.size() == 0 )
               {
  @@ -126,7 +126,7 @@
   
                       if ( m_ready.size() > 0 )
                       {
  -                        obj = (Poolable) m_ready.remove( 0 );
  +                        obj = (Poolable) m_ready.remove();
                       }
                       else
                       {
  @@ -140,7 +140,7 @@
               }
               else
               {
  -                obj = (Poolable)m_ready.remove( 0 );
  +                obj = (Poolable)m_ready.remove();
               }
   
               m_active.add( obj );
  @@ -153,7 +153,7 @@
           }
           finally
           {
  -            m_mutex.unlock();
  +            m_mutex.release();
           }
       }
   
  @@ -170,7 +170,7 @@
                   ((Recyclable) obj).recycle();
               }
   
  -            m_mutex.lock();
  +            m_mutex.acquire();
   
               m_active.remove( m_active.indexOf( obj ) );
   
  @@ -202,7 +202,7 @@
           }
           finally
           {
  -            m_mutex.unlock();
  +            m_mutex.release();
           }
       }
   
  @@ -210,11 +210,11 @@
       {
           try
           {
  -            m_mutex.lock();
  +            m_mutex.acquire();
   
               while( m_ready.size() > 0 )
               {
  -                this.removePoolable( (Poolable) m_ready.remove(0) );
  +                this.removePoolable( (Poolable) m_ready.remove() );
               }
           }
           catch (Exception e)
  @@ -226,7 +226,7 @@
           }
           finally
           {
  -            m_mutex.unlock();
  +            m_mutex.release();
           }
   
           this.m_disposed = true;
  
  
  
  1.8       +5 -5      jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool/SoftResourceLimitingPool.java
  
  Index: SoftResourceLimitingPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/pool/SoftResourceLimitingPool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SoftResourceLimitingPool.java	2001/12/11 09:53:32	1.7
  +++ SoftResourceLimitingPool.java	2001/12/21 16:58:06	1.8
  @@ -11,7 +11,7 @@
    * This is an <code>Pool</code> that caches Poolable objects for reuse.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/12/11 09:53:32 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/12/21 16:58:06 $
    * @since 4.0
    */
   public class SoftResourceLimitingPool
  @@ -86,7 +86,7 @@
       {
           try
           {
  -            m_mutex.lock();
  +            m_mutex.acquire();
   
               this.internalGrow(amount);
           }
  @@ -106,7 +106,7 @@
           }
           finally
           {
  -            m_mutex.unlock();
  +            m_mutex.release();
           }
       }
   
  @@ -114,7 +114,7 @@
       {
           try
           {
  -            m_mutex.lock();
  +            m_mutex.acquire();
   
               this.internalShrink(amount);
           }
  @@ -134,7 +134,7 @@
           }
           finally
           {
  -            m_mutex.unlock();
  +            m_mutex.release();
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message