You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/02/01 11:02:08 UTC

[camel] 02/03: CAMEL-14354: camel-core optimize

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

commit ad1ebeaaa591e0536f6634301e08600d9538fea7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 1 11:16:21 2020 +0100

    CAMEL-14354: camel-core optimize
---
 .../src/main/java/org/apache/camel/processor/Pipeline.java   | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java b/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java
index f1a0b53..7840875 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/Pipeline.java
@@ -93,18 +93,20 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo
     @Override
     public boolean process(Exchange exchange, AsyncCallback callback) {
         if (exchange.isTransacted()) {
-            reactiveExecutor.scheduleSync(() -> Pipeline.this.doProcess(exchange, callback, processors, size, new AtomicInteger(), true));
+            reactiveExecutor.scheduleSync(() -> Pipeline.this.doProcess(exchange, callback, processors, size, new AtomicInteger()));
         } else {
-            reactiveExecutor.scheduleMain(() -> Pipeline.this.doProcess(exchange, callback, processors, size, new AtomicInteger(), true));
+            reactiveExecutor.scheduleMain(() -> Pipeline.this.doProcess(exchange, callback, processors, size, new AtomicInteger()));
         }
         return false;
     }
 
-    protected void doProcess(Exchange exchange, AsyncCallback callback, List<AsyncProcessor> processors, int size, AtomicInteger index, boolean first) {
+    protected void doProcess(Exchange exchange, AsyncCallback callback, List<AsyncProcessor> processors, int size, AtomicInteger index) {
         // optimize to use an atomic index counter for tracking how long we are in the processors list (uses less memory than iterator on array list)
 
         boolean stop = exchange.isRouteStop();
-        boolean more = index.get() < size;
+        int num = index.get();
+        boolean more = num < size;
+        boolean first = num == 0;
 
         if (!stop && more && (first || continueProcessing(exchange, "so breaking out of pipeline", LOG))) {
 
@@ -118,7 +120,7 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo
             AsyncProcessor processor = processors.get(index.getAndIncrement());
 
             processor.process(exchange, doneSync ->
-                    reactiveExecutor.schedule(() -> doProcess(exchange, callback, processors, size, index, false)));
+                    reactiveExecutor.schedule(() -> doProcess(exchange, callback, processors, size, index)));
         } else {
             ExchangeHelper.copyResults(exchange, exchange);