| 1210 | } |
| 1211 | |
| 1212 | void RunTask() { |
| 1213 | #ifdef ARROW_ENABLE_THREADING |
| 1214 | std::unique_lock<std::mutex> lk(mx_); |
| 1215 | num_running_++; |
| 1216 | running_cv_.notify_all(); |
| 1217 | if (!unlocked_cv_.wait_for( |
| 1218 | lk, std::chrono::nanoseconds(static_cast<int64_t>(timeout_seconds_ * 1e9)), |
| 1219 | [this] { return unlocked_; })) { |
| 1220 | status_ &= Status::Invalid("Timed out (" + std::to_string(timeout_seconds_) + "," + |
| 1221 | std::to_string(unlocked_) + |
| 1222 | " seconds) waiting for the gating task to be unlocked"); |
| 1223 | } |
| 1224 | num_finished_++; |
| 1225 | #else |
| 1226 | // can't wait here for anything, so make a future to do the waiting |
| 1227 | num_running_++; |
| 1228 | auto future = RunTaskFuture(); |
| 1229 | future.Wait(); |
| 1230 | #endif |
| 1231 | } |
| 1232 | |
| 1233 | Status WaitForRunning(int count) { |
| 1234 | #ifdef ARROW_ENABLE_THREADING |