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/event/src/test/org/apache/excalibur/mpool/test PoolComparisonProfileAbstract.java
Date Wed, 14 Aug 2002 16:59:55 GMT
bloritsch    2002/08/14 09:59:55

  Modified:    event/src/java/org/apache/excalibur/mpool
                        BlockingFixedSizePool.java
               event/src/java/org/apache/excalibur/thread/impl
                        DefaultThreadPool.java
               event/src/test/org/apache/excalibur/mpool/test
                        PoolComparisonProfileAbstract.java
  Log:
  fix bug 11696 and bug 11694
  
  Revision  Changes    Path
  1.2       +24 -22    jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool/BlockingFixedSizePool.java
  
  Index: BlockingFixedSizePool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/mpool/BlockingFixedSizePool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BlockingFixedSizePool.java	9 Aug 2002 19:01:12 -0000	1.1
  +++ BlockingFixedSizePool.java	14 Aug 2002 16:59:55 -0000	1.2
  @@ -53,6 +53,7 @@
   import org.apache.avalon.excalibur.collections.Buffer;
   import org.apache.avalon.excalibur.collections.FixedSizeBuffer;
   import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
    * This is an <code>Pool</code> that caches Poolable objects for reuse.
  @@ -63,7 +64,7 @@
    * @since 4.1
    */
   public final class BlockingFixedSizePool
  -    implements Pool, Disposable
  +    implements Pool, Disposable, Initializable
   {
       private boolean m_disposed = false;
       private final Buffer m_buffer;
  @@ -87,8 +88,12 @@
           m_buffer = new FixedSizeBuffer( size );
           m_maxSize = size;
           m_factory = factory;
  +    }
   
  -        for( int i = 0; i < size; i++ )
  +    public void initialize()
  +        throws Exception
  +    {
  +        for( int i = 0; i < m_maxSize; i++ )
           {
               m_buffer.add( newInstance() );
           }
  @@ -115,27 +120,24 @@
   
                       do
                       {
  -                        if ( blockWait > 0 )
  +                        try
  +                        {
  +                            m_semaphore.wait( blockWait );
  +                        }
  +                        catch ( InterruptedException ie )
  +                        {}
  +
  +                        if ( m_disposed )
  +                        {
  +                            throw new IllegalStateException( "Pool disposed of while waiting
for resources to free up" );
  +                        }
  +
  +                        if ( m_buffer.isEmpty() )
                           {
  -                            try
  -                            {
  -                                m_semaphore.wait( blockWait );
  -                            }
  -                            catch ( InterruptedException ie )
  -                            {}
  -
  -                            if ( m_disposed )
  -                            {
  -                                throw new IllegalStateException( "Pool disposed of while
waiting for resources to free up" );
  -                            }
  -
  -                            if ( m_buffer.isEmpty() )
  -                            {
  -                                blockWait = m_timeout -
  -                                    ( System.currentTimeMillis() - blockStart );
  -                            }
  +                            blockWait = m_timeout -
  +                                ( System.currentTimeMillis() - blockStart );
                           }
  -                    } while ( m_buffer.isEmpty() );
  +                    } while ( m_buffer.isEmpty() && blockWait > 0 );
                   }
                   else
                   {
  
  
  
  1.4       +2 -0      jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/thread/impl/DefaultThreadPool.java
  
  Index: DefaultThreadPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/thread/impl/DefaultThreadPool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultThreadPool.java	9 Aug 2002 19:01:12 -0000	1.3
  +++ DefaultThreadPool.java	14 Aug 2002 16:59:55 -0000	1.4
  @@ -111,6 +111,7 @@
           super( name );
           m_pool = new BlockingFixedSizePool( this, capacity, timeout );
           m_context = context;
  +        m_pool.initialize();
       }
   
       public void enableLogging( final Logger logger )
  @@ -138,6 +139,7 @@
           worker.setDaemon( true );
           worker.enableLogging( m_logger );
           worker.start();
  +
           return worker;
       }
   
  
  
  
  1.4       +4 -1      jakarta-avalon-excalibur/event/src/test/org/apache/excalibur/mpool/test/PoolComparisonProfileAbstract.java
  
  Index: PoolComparisonProfileAbstract.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/event/src/test/org/apache/excalibur/mpool/test/PoolComparisonProfileAbstract.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PoolComparisonProfileAbstract.java	13 Aug 2002 08:15:21 -0000	1.3
  +++ PoolComparisonProfileAbstract.java	14 Aug 2002 16:59:55 -0000	1.4
  @@ -150,6 +150,7 @@
   
           FixedSizePool poolA = new FixedSizePool( factory, max );
           BlockingFixedSizePool poolB = new BlockingFixedSizePool( factory, max, blockTimeout
);
  +        poolB.initialize();
   
           generalTest( name, poolA, poolB, 100, factory );
       }
  @@ -174,6 +175,7 @@
   
           FixedSizePool poolA = new FixedSizePool( factory, max );
           BlockingFixedSizePool poolB = new BlockingFixedSizePool( factory, max, blockTimeout
);
  +        poolB.initialize();
   
           generalTest( name, poolA, poolB, 100, factory );
       }
  @@ -198,6 +200,7 @@
   
           FixedSizePool poolA = new FixedSizePool( factory, max );
           BlockingFixedSizePool poolB = new BlockingFixedSizePool( factory, max, blockTimeout
);
  +        poolB.initialize();
   
           generalTest( name, poolA, poolB, 100, factory );
       }
  
  
  

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