bakaid commented on a change in pull request #735: WIP: MINIFICPP-1158 - Event 
driven processors can starve each other
URL: https://github.com/apache/nifi-minifi-cpp/pull/735#discussion_r381970926
 
 

 ##########
 File path: libminifi/src/EventDrivenSchedulingAgent.cpp
 ##########
 @@ -32,28 +29,24 @@ namespace apache {
 namespace nifi {
 namespace minifi {
 
-uint64_t EventDrivenSchedulingAgent::run(const 
std::shared_ptr<core::Processor> &processor, const 
std::shared_ptr<core::ProcessContext> &processContext,
+utils::ComplexResult EventDrivenSchedulingAgent::run(const 
std::shared_ptr<core::Processor> &processor, const 
std::shared_ptr<core::ProcessContext> &processContext,
                                          const 
std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) {
-  while (this->running_) {
-    bool shouldYield = this->onTrigger(processor, processContext, 
sessionFactory);
-
-    if (processor->isYield()) {
-      // Honor the yield
-      return processor->getYieldTime();
-    } else if (shouldYield && this->bored_yield_duration_ > 0) {
-      // No work to do or need to apply back pressure
-      return this->bored_yield_duration_;
-    }
-
-    // Block until work is available
-
-    processor->waitForWork(1000);
-
-    if (!processor->isWorkAvailable()) {
-      return 1000;
+  if (this->running_ && processor->isRunning()) {
+    auto start_time = std::chrono::steady_clock::now();
+    // trigger processor until it has work to do, but no more than half a sec
+    while (std::chrono::steady_clock::now() - start_time < 
std::chrono::milliseconds(500)) {
 
 Review comment:
   I think we might have to check `processor->isRunning()` in this loop as well.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to