MCPcopy Create free account
hub / github.com/apache/arrow / SleepABit

Function SleepABit

cpp/src/arrow/testing/gtest_util.cc:784–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

782
783#ifdef _WIN32
784void SleepABit() {
785 LARGE_INTEGER freq, start, now;
786 QueryPerformanceFrequency(&freq);
787 // 1 ms
788 auto desired = freq.QuadPart / 1000;
789 if (desired <= 0) {
790 // Fallback to STL sleep if high resolution clock not available, tests may fail,
791 // shouldn't really happen
792 SleepFor(1e-3);
793 return;
794 }
795 QueryPerformanceCounter(&start);
796 while (true) {
797 std::this_thread::yield();
798 QueryPerformanceCounter(&now);
799 auto elapsed = now.QuadPart - start.QuadPart;
800 if (elapsed > desired) {
801 break;
802 }
803 }
804}
805#else
806// std::this_thread::sleep_for should be high enough resolution on non-Windows systems
807void SleepABit() { SleepFor(1e-3); }

Callers 15

TEST_FFunction · 0.85
genMethod · 0.85
CheckScannerBackpressureFunction · 0.85
TEST_FFunction · 0.85
AssertCannotConsumeMethod · 0.85
SlowTaskImplFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
genMethod · 0.85
SleepABitAsyncFunction · 0.85
WaitForEndOrUnlockedMethod · 0.85
TESTFunction · 0.85

Calls 1

SleepForFunction · 0.85

Tested by

no test coverage detected