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 2021/02/28 17:56:23 UTC

[camel] branch master updated: camel-core - Optimize pipeline to reduce object allocations

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 306b706  camel-core - Optimize pipeline to reduce object allocations
306b706 is described below

commit 306b706f2dc0e2d212d5091ba24b113148a6cbf6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Feb 28 17:23:45 2021 +0100

    camel-core - Optimize pipeline to reduce object allocations
---
 .../src/main/java/org/apache/camel/processor/Pipeline.java   | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Pipeline.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Pipeline.java
index 0beeea6..7901bea 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Pipeline.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Pipeline.java
@@ -19,7 +19,6 @@ package org.apache.camel.processor;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import org.apache.camel.AsyncCallback;
@@ -61,12 +60,11 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo
 
         private final Exchange exchange;
         private final AsyncCallback callback;
-        private final AtomicInteger index;
+        private int index;
 
-        PipelineTask(Exchange exchange, AsyncCallback callback, AtomicInteger index) {
+        PipelineTask(Exchange exchange, AsyncCallback callback) {
             this.exchange = exchange;
             this.callback = callback;
-            this.index = index;
         }
 
         @Override
@@ -77,7 +75,7 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo
         @Override
         public void run() {
             boolean stop = exchange.isRouteStop();
-            int num = index.get();
+            int num = index;
             boolean more = num < size;
             boolean first = num == 0;
 
@@ -90,7 +88,7 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo
                 }
 
                 // get the next processor
-                AsyncProcessor processor = processors.get(index.getAndIncrement());
+                AsyncProcessor processor = processors.get(index++);
 
                 processor.process(exchange, this);
             } else {
@@ -144,7 +142,7 @@ public class Pipeline extends AsyncProcessorSupport implements Navigate<Processo
     @Override
     public boolean process(Exchange exchange, AsyncCallback callback) {
         // create task which has state used during routing
-        PipelineTask task = new PipelineTask(exchange, callback, new AtomicInteger());
+        PipelineTask task = new PipelineTask(exchange, callback);
 
         if (exchange.isTransacted()) {
             reactiveExecutor.scheduleSync(task);