| 1157 | } |
| 1158 | |
| 1159 | void RunTask() { |
| 1160 | #ifdef ARROW_ENABLE_THREADING |
| 1161 | std::unique_lock<std::mutex> lk(mx_); |
| 1162 | num_running_++; |
| 1163 | running_cv_.notify_all(); |
| 1164 | if (!unlocked_cv_.wait_for( |
| 1165 | lk, std::chrono::nanoseconds(static_cast<int64_t>(timeout_seconds_ * 1e9)), |
| 1166 | [this] { return unlocked_; })) { |
| 1167 | status_ &= Status::Invalid("Timed out (" + std::to_string(timeout_seconds_) + "," + |
| 1168 | std::to_string(unlocked_) + |
| 1169 | " seconds) waiting for the gating task to be unlocked"); |
| 1170 | } |
| 1171 | num_finished_++; |
| 1172 | #else |
| 1173 | // can't wait here for anything, so make a future to do the waiting |
| 1174 | num_running_++; |
| 1175 | auto future = RunTaskFuture(); |
| 1176 | future.Wait(); |
| 1177 | #endif |
| 1178 | } |
| 1179 | |
| 1180 | Status WaitForRunning(int count) { |
| 1181 | #ifdef ARROW_ENABLE_THREADING |