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

Function SleepABit

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

Source from the content-addressed store, hash-verified

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