cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1360701 - /cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Date Thu, 12 Jul 2012 14:29:02 GMT
Author: dkulp
Date: Thu Jul 12 14:29:02 2012
New Revision: 1360701

URL: http://svn.apache.org/viewvc?rev=1360701&view=rev
Log:
Merged revisions 1360677 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1360677 | dkulp | 2012-07-12 09:47:43 -0400 (Thu, 12 Jul 2012) | 11 lines

  Merged revisions 1360406 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1360406 | dkulp | 2012-07-11 17:15:48 -0400 (Wed, 11 Jul 2012) | 3 lines

    If another thread is working on adding threads, just return and let it
    handle it.

  ........

........

Modified:
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java

Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1360701&r1=1360700&r2=1360701&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Thu Jul 12 14:29:02 2012
@@ -71,7 +71,7 @@ public class AutomaticWorkQueueImpl impl
     
     AWQThreadFactory threadFactory;
     ReentrantLock mainLock;
-    
+    final ReentrantLock addThreadLock = new ReentrantLock();
     
     DelayQueue<DelayedTaskWrapper> delayQueue;
     WatchDog watchDog;
@@ -440,20 +440,25 @@ public class AutomaticWorkQueueImpl impl
         ex.execute(r);
         if (addWorkerMethod != null 
             && !ex.getQueue().isEmpty() 
-            && this.approxThreadCount < highWaterMark) {
-            mainLock.lock();
+            && this.approxThreadCount < highWaterMark
+            && addThreadLock.tryLock()) {
             try {
-                int ps = this.getPoolSize();
-                int sz = executor.getQueue().size();
-                int sz2 = this.getActiveCount();
-                
-                if ((sz + sz2) > ps) {
-                    ReflectionUtil.setAccessible(addWorkerMethod).invoke(executor, addWorkerArgs);
+                mainLock.lock();
+                try {
+                    int ps = this.getPoolSize();
+                    int sz = executor.getQueue().size();
+                    int sz2 = this.getActiveCount();
+                    
+                    if ((sz + sz2) > ps) {
+                        ReflectionUtil.setAccessible(addWorkerMethod).invoke(executor, addWorkerArgs);
+                    }
+                } catch (Exception exc) {
+                    //ignore
+                } finally {
+                    mainLock.unlock();
                 }
-            } catch (Exception exc) {
-                //ignore
             } finally {
-                mainLock.unlock();
+                addThreadLock.unlock();
             }
         }
     }



Mime
View raw message