[camel] branch master updated: CAMEL-14354: Optimize core

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-14354: Optimize core

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 59b496d  CAMEL-14354: Optimize core
59b496d is described below

commit 59b496dff3ce73f9c1ee260a15521bfb300add95
Author: Claus Ibsen <[hidden email]>
AuthorDate: Wed Jan 22 09:41:47 2020 +0100

    CAMEL-14354: Optimize core
---
 .../apache/camel/impl/engine/DefaultReactiveExecutor.java | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultReactiveExecutor.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultReactiveExecutor.java
index f9d4cde..e33b85f 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultReactiveExecutor.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultReactiveExecutor.java
@@ -40,8 +40,8 @@ public class DefaultReactiveExecutor extends ServiceSupport implements ReactiveE
     private final ThreadLocal<Worker> workers = ThreadLocal.withInitial(new Supplier<Worker>() {
         @Override
         public Worker get() {
-            createdWorkers.incrementAndGet();
-            return new Worker(DefaultReactiveExecutor.this);
+            int number = createdWorkers.incrementAndGet();
+            return new Worker(number, DefaultReactiveExecutor.this);
         }
     });
 
@@ -92,17 +92,22 @@ public class DefaultReactiveExecutor extends ServiceSupport implements ReactiveE
 
     @Override
     protected void doStop() throws Exception {
-        // noop
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Stopping DefaultReactiveExecutor [createdWorkers: {}, runningWorkers: {}, pendingTasks: {}]",
+                    getCreatedWorkers(), getRunningWorkers(), getPendingTasks());
+        }
     }
 
     private static class Worker {
 
+        private final int number;
         private final DefaultReactiveExecutor executor;
         private volatile Deque<Runnable> queue = new ArrayDeque<>();
         private volatile Deque<Deque<Runnable>> back;
         private volatile boolean running;
 
-        public Worker(DefaultReactiveExecutor executor) {
+        public Worker(int number, DefaultReactiveExecutor executor) {
+            this.number = number;
             this.executor = executor;
         }
 
@@ -143,7 +148,7 @@ public class DefaultReactiveExecutor extends ServiceSupport implements ReactiveE
                         try {
                             executor.pendingTasks.decrementAndGet();
                             if (LOG.isTraceEnabled()) {
-                                LOG.trace("Running: {}", runnable);
+                                LOG.trace("Worker #{} running: {}", number, runnable);
                             }
                             polled.run();
                         } catch (Throwable t) {