From 32605524ff730cae11d7416948af04c72dcdbefc Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 25 Oct 2018 02:51:50 -0500 Subject: [PATCH] Added flag to allow skipping a lock when applicable --- DS4Windows/DS4Library/DS4Device.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 6412903..f6d4fd7 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -398,6 +398,7 @@ namespace DS4Windows private bool timeoutExecuted = false; private bool timeoutEvent = false; private bool runCalib; + private bool hasInputEvts = false; public bool ShouldRunCalib() { return runCalib; @@ -1090,13 +1091,18 @@ namespace DS4Windows cState.CopyTo(pState); - lock (eventQueueLock) + if (hasInputEvts) { - Action tempAct = null; - for (int actInd = 0, actLen = eventQueue.Count; actInd < actLen; actInd++) + lock (eventQueueLock) { - tempAct = eventQueue.Dequeue(); - tempAct.Invoke(); + Action tempAct = null; + for (int actInd = 0, actLen = eventQueue.Count; actInd < actLen; actInd++) + { + tempAct = eventQueue.Dequeue(); + tempAct.Invoke(); + } + + hasInputEvts = false; } } } @@ -1467,6 +1473,7 @@ namespace DS4Windows lock (eventQueueLock) { eventQueue.Enqueue(act); + hasInputEvts = true; } }