Skip to content

SuspendingClock on Windows does not suspend #63225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
16 changes: 4 additions & 12 deletions stdlib/public/Concurrency/Clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,10 @@ void swift_get_time(
*seconds = suspending.tv_sec;
*nanoseconds = suspending.tv_nsec;
#elif defined(_WIN32)
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
*seconds = count.QuadPart / freq.QuadPart;
if (freq.QuadPart < 1000000000) {
*nanoseconds =
((count.QuadPart % freq.QuadPart) * 1000000000) / freq.QuadPart;
} else {
*nanoseconds =
(count.QuadPart % freq.QuadPart) * (1000000000.0 / freq.QuadPart);
}
ULONGLONG unbiasedTime;
QueryUnbiasedInterruptTimePrecise(&unbiasedTime);
*seconds = unbiasedTime / 10000000ULL; // unit is 100ns
*nanoseconds = unbiasedTime % 10000000ULL;
#else
#error Missing platform suspending time definition
#endif
Expand Down