cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1362520 - /cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Date Tue, 17 Jul 2012 14:42:46 GMT
Author: dkulp
Date: Tue Jul 17 14:42:45 2012
New Revision: 1362520

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

........
  r1360701 | dkulp | 2012-07-12 10:29:02 -0400 (Thu, 12 Jul 2012) | 19 lines

  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.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1362520&r1=1362519&r2=1362520&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
Tue Jul 17 14:42:45 2012
@@ -60,6 +60,7 @@ public class AutomaticWorkQueueImpl exte
     final int corePoolSize;
     final int maxPoolSize;
     final ReentrantLock mainLock;
+    final ReentrantLock addThreadLock = new ReentrantLock();
 
     public AutomaticWorkQueueImpl() {
         this(DEFAULT_MAX_QUEUE_SIZE);
@@ -382,21 +383,27 @@ public class AutomaticWorkQueueImpl exte
         super.execute(r);
         if (addWorkerMethod != null 
             && !getQueue().isEmpty() 
-            && getPoolSize() < maxPoolSize) {
-            mainLock.lock();
+            && getPoolSize() < maxPoolSize
+            && addThreadLock.tryLock()) {
+            
             try {
-                int ps = this.getPoolSize();
-                int sz = getQueue().size();
-                int sz2 = this.getActiveCount();
+                mainLock.lock();
+                try {
+                    int ps = this.getPoolSize();
+                    int sz = getQueue().size();
+                    int sz2 = this.getActiveCount();
                 
-                if ((sz + sz2) > ps) {
-                    addWorkerMethod.setAccessible(true);
-                    addWorkerMethod.invoke(this, addWorkerArgs);
+                    if ((sz + sz2) > ps) {
+                        addWorkerMethod.setAccessible(true);
+                        addWorkerMethod.invoke(this, addWorkerArgs);
+                    }
+                } catch (Exception ex) {
+                    //ignore
+                } finally {
+                    mainLock.unlock();
                 }
-            } catch (Exception ex) {
-                //ignore
             } finally {
-                mainLock.unlock();
+                addThreadLock.unlock();
             }
         }
     }



Mime
View raw message