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