summaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-11-25 19:43:21 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-11-25 19:43:21 +0100
commit8e1a6ea4319e6f38cecc36a06e2e5384678ecf83 (patch)
treedc0786e6acb24a34278ee2e8a2884dac0ee4d452 /platform
parentf952bfe9985ad8f507cc29b2c7601bbba18b8039 (diff)
downloadredot-engine-8e1a6ea4319e6f38cecc36a06e2e5384678ecf83.tar.gz
Revert "Make delay_usec more precise"
This reverts commit df3367f3343ec5acc579205479642d7275f3e12b. Fixes #99593.
Diffstat (limited to 'platform')
-rw-r--r--platform/windows/os_windows.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index a25b7ea4ca..416016b112 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -817,22 +817,10 @@ double OS_Windows::get_unix_time() const {
}
void OS_Windows::delay_usec(uint32_t p_usec) const {
- constexpr uint32_t tolerance = 1000 + 20;
-
- uint64_t t0 = get_ticks_usec();
- uint64_t target_time = t0 + p_usec;
-
- // Calculate sleep duration with a tolerance for fine-tuning.
- if (p_usec > tolerance) {
- uint32_t coarse_sleep_usec = p_usec - tolerance;
- if (coarse_sleep_usec >= 1000) {
- Sleep(coarse_sleep_usec / 1000);
- }
- }
-
- // Spin-wait until we reach the precise target time.
- while (get_ticks_usec() < target_time) {
- YieldProcessor();
+ if (p_usec < 1000) {
+ Sleep(1);
+ } else {
+ Sleep(p_usec / 1000);
}
}