Skip to content

Commit

Permalink
SuspendingClock on Windows does not suspend #63224
Browse files Browse the repository at this point in the history
  • Loading branch information
grynspan committed Jan 25, 2023
1 parent cfa0d63 commit 399945e
Showing 1 changed file with 4 additions and 12 deletions.
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;
(void)QueryUnbiasedInterruptTime(&unbiasedTime);
*seconds = unbiasedTime / 10000000ULL; // unit is 100ns
*nanoseconds = unbiasedTime % 10000000ULL;
#else
#error Missing platform suspending time definition
#endif
Expand Down

0 comments on commit 399945e

Please sign in to comment.