| 759 | } |
| 760 | |
| 761 | void SleepFor(double seconds) { |
| 762 | #ifdef ARROW_ENABLE_THREADING |
| 763 | std::this_thread::sleep_for( |
| 764 | std::chrono::nanoseconds(static_cast<int64_t>(seconds * 1e9))); |
| 765 | #else |
| 766 | using Clock = std::chrono::steady_clock; |
| 767 | using DurationDouble = std::chrono::duration<double>; |
| 768 | |
| 769 | auto secs_left = DurationDouble(seconds); |
| 770 | auto start_time = Clock::now(); |
| 771 | auto end_time = start_time + secs_left; |
| 772 | while (Clock::now() < end_time) { |
| 773 | bool run_task = arrow::internal::SerialExecutor::RunTasksOnAllExecutors(); |
| 774 | if (!run_task) { |
| 775 | // all executors are empty, just sleep for the rest of the time |
| 776 | std::this_thread::sleep_for(end_time - Clock::now()); |
| 777 | } |
| 778 | // run one task then check time |
| 779 | } |
| 780 | #endif |
| 781 | } |
| 782 | |
| 783 | #ifdef _WIN32 |
| 784 | void SleepABit() { |
no outgoing calls
no test coverage detected