westonpace commented on a change in pull request #9095:
URL: https://github.com/apache/arrow/pull/9095#discussion_r564862995



##########
File path: cpp/src/arrow/util/task_group.cc
##########
@@ -135,6 +149,18 @@ class ThreadedTaskGroup : public TaskGroup {
       // before cv.notify_one() has returned
       std::unique_lock<std::mutex> lock(mutex_);
       cv_.notify_one();
+      if (completion_future_.has_value()) {
+        // MarkFinished could be slow.  We don't want to call it while we are 
holding
+        // the lock.
+        // TODO: If optional is thread safe then we can skip this locking 
entirely
+        auto future = *completion_future_;
+        auto finished = completion_future_->is_finished();
+        auto status = status_;
+        lock.unlock();
+        if (!finished) {
+          future.MarkFinished(status);

Review comment:
       Indeed.  I will make a test case to expose this.




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


Reply via email to