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

Function SleepABit

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

Source from the content-addressed store, hash-verified

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