From 9ffaf56630587e511e6d5ed0c633582b1164d579 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 27 Aug 2011 18:06:23 +0000 Subject: [PATCH] throttle timing refinement --- BizHawk.MultiClient/Throttle.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BizHawk.MultiClient/Throttle.cs b/BizHawk.MultiClient/Throttle.cs index dfe4032789..ae75641cbd 100644 --- a/BizHawk.MultiClient/Throttle.cs +++ b/BizHawk.MultiClient/Throttle.cs @@ -129,6 +129,9 @@ namespace BizHawk.MultiClient [DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")] static extern uint timeBeginPeriod(uint uMilliseconds); + [DllImport("kernel32.dll")] + static extern bool SwitchToThread(); + static int tmethod; static ulong afsfreq; static ulong tfreq; @@ -319,9 +322,8 @@ namespace BizHawk.MultiClient } else if (sleepy > 0) // spin for <1 millisecond waits { - Thread.Sleep(0); + SwitchToThread(); // limit to other threads on the same CPU core for other short waits } - //SwitchToThread(); // limit to other threads on the same CPU core for other short waits goto waiter; } if ((ttime - ltime) >= (tfreq * 4 / desiredfps))