mac-op commented on code in PR #25:
URL: https://github.com/apache/uima-uimacpp/pull/25#discussion_r1727751041


##########
src/framework/annotator_mgr.cpp:
##########
@@ -583,7 +576,185 @@ namespace uima {
       }
 
       UIMA_ANNOTATOR_TIMING(iv_clTimerLaunchProcess.stop());
-      return(utRetVal);
+      return utRetVal;
+    }
+
+    CAS *AnnotatorManager::processUntilNextOutputCas() {
+      unique_ptr<Flow> flow{};
+      while (true) {
+        CAS *currentCas = nullptr;
+        Step nextStep;
+        flow = nullptr;
+
+        // get a cas from the stack
+        if (casIterStack.empty())
+          return nullptr;
+
+        StackFrame &frame = casIterStack.top();
+        try {
+          if (frame.casMultiplier && frame.casMultiplier->hasNext()) {
+            currentCas = &frame.casMultiplier->next();
+            // compute flow for newly produced CAS
+            flow = frame.originalFlow->newCasProduced(*currentCas, 
frame.lastEngineKey);
+          }
+        } catch (Exception &exception) {
+          if (!frame.originalFlow->continueOnFailure(frame.lastEngineKey /* 
,exception */))
+            throw;
+        }
+
+        if (!currentCas) {
+          // if there is no more output CASes from the stack, take the 
original CAS that was processed by
+          // the CAS Multiplier and continue with its flow
+          currentCas = frame.originalCas;
+          flow = std::move(frame.originalFlow);
+          currentCas->setCurrentComponentInfo(nullptr);
+          casIterStack.pop();
+        }
+
+        activeCASes.insert(currentCas);

Review Comment:
   I chose to release everything in the caller launchProcessDocument instead 
with a try catch block, because I thought this method is busy enough.



-- 
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: dev-unsubscr...@uima.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to