Author: fhanik
Date: Tue Jun  9 18:51:07 2009
New Revision: 783094

URL: http://svn.apache.org/viewvc?rev=783094&view=rev
Log:
Revert http://svn.apache.org/viewvc?view=rev&revision=763566
The code is not the same as it was before. The patch applied, while it looks 
the same will grow the pool the max threads even though it doesn't need to


Modified:
    tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java?rev=783094&r1=783093&r2=783094&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/threads/TaskQueue.java Tue Jun  9 
18:51:07 2009
@@ -59,13 +59,15 @@
     }
 
     public boolean offer(Runnable o) {
-        if (parent != null && 
parent.getPoolSize()<parent.getMaximumPoolSize()){
-               return false;
-        } else {
-            //if we reached here, we need to add it to the queue
-            //or can't do any checks
-            return super.offer(o);
-        }
-
+      //we can't do any checks
+        if (parent==null) return super.offer(o);
+        //we are maxed out on threads, simply queue the object
+        if (parent.getPoolSize() == parent.getMaximumPoolSize()) return 
super.offer(o);
+        //we have idle threads, just add it to the queue
+        if (parent.getActiveCount()<(parent.getPoolSize())) return 
super.offer(o);
+        //if we have less threads than maximum force creation of a new thread
+        if (parent.getPoolSize()<parent.getMaximumPoolSize()) return false;
+        //if we reached here, we need to add it to the queue
+        return super.offer(o);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to