pitrou commented on a change in pull request #9720:
URL: https://github.com/apache/arrow/pull/9720#discussion_r595837653



##########
File path: cpp/src/arrow/testing/gtest_util.cc
##########
@@ -719,43 +719,44 @@ ExtensionTypeGuard::~ExtensionTypeGuard() {
   }
 }
 
-class GatingTask::Impl {
+class GatingTask::Impl : public std::enable_shared_from_this<GatingTask::Impl> 
{
  public:
   explicit Impl(double timeout_seconds)
       : timeout_seconds_(timeout_seconds), status_(), unlocked_(false) {}
 
   ~Impl() {
-    std::unique_lock<std::mutex> lk(mx_);
-    if (!finished_cv_.wait_for(
-            lk, std::chrono::nanoseconds(static_cast<int64_t>(timeout_seconds_ 
* 1e9)),
-            [this] { return num_finished_ == num_launched_; })) {
+    if (num_running_ != num_launched_) {
       ADD_FAILURE()
-          << "A GatingTask instance was destroyed but the underlying tasks did 
not "
+          << "A GatingTask instance was destroyed but some underlying tasks 
did not "
+             "start running"
+          << std::endl;
+    } else if (num_finished_ != num_launched_) {
+      ADD_FAILURE()
+          << "A GatingTask instance was destroyed but some underlying tasks 
did not "
              "finish running"
           << std::endl;
     }
   }
 
   std::function<void()> Task() {
     num_launched_++;

Review comment:
       I think Task() is only meant to be called from the main thread.




----------------------------------------------------------------
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:
[email protected]


Reply via email to