Skip to content

Commit 399945e

Browse files
committed
SuspendingClock on Windows does not suspend #63224
1 parent cfa0d63 commit 399945e

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

stdlib/public/Concurrency/Clock.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,10 @@ void swift_get_time(
8787
*seconds = suspending.tv_sec;
8888
*nanoseconds = suspending.tv_nsec;
8989
#elif defined(_WIN32)
90-
LARGE_INTEGER freq;
91-
QueryPerformanceFrequency(&freq);
92-
LARGE_INTEGER count;
93-
QueryPerformanceCounter(&count);
94-
*seconds = count.QuadPart / freq.QuadPart;
95-
if (freq.QuadPart < 1000000000) {
96-
*nanoseconds =
97-
((count.QuadPart % freq.QuadPart) * 1000000000) / freq.QuadPart;
98-
} else {
99-
*nanoseconds =
100-
(count.QuadPart % freq.QuadPart) * (1000000000.0 / freq.QuadPart);
101-
}
90+
ULONGLONG unbiasedTime;
91+
(void)QueryUnbiasedInterruptTime(&unbiasedTime);
92+
*seconds = unbiasedTime / 10000000ULL; // unit is 100ns
93+
*nanoseconds = unbiasedTime % 10000000ULL;
10294
#else
10395
#error Missing platform suspending time definition
10496
#endif

0 commit comments

Comments
 (0)