apupier commented on code in PR #30711:
URL: https://github.com/apache/camel/pull/30711#discussion_r4681324756


##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/semantic/SemanticEvaluateConsole.java:
##########
@@ -58,16 +62,33 @@ public class SemanticEvaluateConsole extends 
AbstractDevConsole {
               javaType = "java.lang.Long")
     public static final String TIMEOUT = "timeout";
 
+    private final AtomicInteger active = new AtomicInteger();
     private ExecutorService executor;
     // A resolver-created console may be called without starting it; only an 
explicit stop rejects calls.
-    private boolean stopped;
+    private volatile boolean stopped;
+
+    private boolean tryAcquire() {
+        while (true) {
+            int count = active.get();
+            if (count >= 2) {
+                return false;
+            }
+            if (active.compareAndSet(count, count + 1)) {
+                return true;
+            }
+        }
+    }
+
+    private void release() {
+        active.decrementAndGet();

Review Comment:
   We intentionally avoid clamping here: with the `claimed` flag guaranteeing 
that every accepted request releases exactly once, `decrementAndGet()` 
maintains exact 1:1 slot accounting without masking potential permit leaks or 
uncoordinated resets across lifecycle stop/restarts.
   
   _IBM Bob on behalf of apupier_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to