adam-markovics commented on code in PR #1309:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1309#discussion_r854130310


##########
libminifi/src/utils/ThreadPool.cpp:
##########
@@ -200,6 +203,26 @@ template<typename T>
 void ThreadPool<T>::stopTasks(const TaskId &identifier) {
   std::unique_lock<std::mutex> lock(worker_queue_mutex_);
   task_status_[identifier] = false;
+
+  // remove tasks belonging to identifier from worker_queue_
+  worker_queue_.remove([&] (const Worker<T>& worker) { return 
worker.getIdentifier() == identifier; });
+
+  // also remove from delayed_worker_queue_
+  decltype(delayed_worker_queue_) newDelayedWorkerQueue;
+  while (!delayed_worker_queue_.empty()) {
+    Worker<T> task = 
std::move(const_cast<Worker<T>&>(delayed_worker_queue_.top()));
+    delayed_worker_queue_.pop();
+    if (task.getIdentifier() != identifier) {
+      newDelayedWorkerQueue.push(std::move(task));
+    }
+  }
+  delayed_worker_queue_ = std::move(newDelayedWorkerQueue);
+
+  // if tasks are progress, wait for their completion

Review Comment:
   Done.



-- 
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