larryi      01/02/28 11:24:35

  Modified:    src/share/org/apache/tomcat/util/collections SimplePool.java
  Log:
  Updated to match the patch made to the  tomcat_32 version.  That
  patch cleaned up the code a little better.
  
  Submitted by: [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.2       +16 -21    
jakarta-tomcat/src/share/org/apache/tomcat/util/collections/SimplePool.java
  
  Index: SimplePool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/collections/SimplePool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimplePool.java   2000/12/07 19:52:51     1.1
  +++ SimplePool.java   2001/02/28 19:24:32     1.2
  @@ -1,4 +1,8 @@
   /*
  + * $Header: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/collections/SimplePool.java,v
 1.2 2001/02/28 19:24:32 larryi Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/02/28 19:24:32 $
  + *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -59,11 +63,6 @@
   
   package org.apache.tomcat.util.collections;
   
  -import java.util.zip.*;
  -import java.net.*;
  -import java.util.*;
  -import java.io.*;
  -
   /**
    * Simple object pool. Based on ThreadPool and few other classes
    *
  @@ -79,9 +78,6 @@
       private Object pool[];
   
       private int max;
  -    private int minSpare;
  -    private int maxSpare;
  -
       private int current=-1;
   
       Object lock;
  @@ -106,12 +102,11 @@
        * Add the object to the pool, silent nothing if the pool is full
        */
       public  void put(Object o) {
  -     int idx=-1;
        synchronized( lock ) {
  -         if( current < max - 1 )
  -             idx=++current;
  -         if( idx >= 0 ) 
  -             pool[idx]=o;
  +         if( current < (max-1) ) {
  +             current += 1;
  +             pool[current] = o;
  +            }
        }
       }
   
  @@ -119,20 +114,20 @@
        * Get an object from the pool, null if the pool is empty.
        */
       public  Object get() {
  -     int idx=-1;
  +     Object item = null;
        synchronized( lock ) {
  -         if( current >= 0 )
  -             idx=current--;
  -         if( idx >= 0  ) 
  -             return pool[idx];
  +         if( current >= 0 ) {
  +             item = pool[current];
  +             current -= 1;
  +         }
        }
  -     return null;
  +     return item;
       }
   
  -    /** Return the size of the pool
  +    /**
  +     * Return the size of the pool
        */
       public int getMax() {
        return max;
       }
  -
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to