From c2d088f232579e4f09e4c24d117ff76463be6f24 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 23 Feb 2022 21:49:35 +0100 Subject: [PATCH] pipeline: Don't use Sleep(1) to yield on Windows Use Sleep(0) instead. Sleep(0) is not guaranteed to yield, which is a problem, but Sleep(1) can easily take up to 16 ms, which is really unacceptable except in very low-priority thread. But really, you shouldn't be relying on force_yield() for anything except with the SIMPLE_THREADS model. There is also SwitchToThread(), but in fact it is even weaker than Sleep(0). --- panda/src/pipeline/threadWin32Impl.I | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pipeline/threadWin32Impl.I b/panda/src/pipeline/threadWin32Impl.I index 14f912f917..ca236b78f0 100644 --- a/panda/src/pipeline/threadWin32Impl.I +++ b/panda/src/pipeline/threadWin32Impl.I @@ -76,7 +76,7 @@ sleep(double seconds) { */ INLINE void ThreadWin32Impl:: yield() { - Sleep(1); + Sleep(0); } /**