Added flag to allow skipping a lock when applicable

This commit is contained in:
Travis Nickles 2018-10-25 02:51:50 -05:00
parent ce78793dea
commit 32605524ff

View File

@ -398,6 +398,7 @@ namespace DS4Windows
private bool timeoutExecuted = false; private bool timeoutExecuted = false;
private bool timeoutEvent = false; private bool timeoutEvent = false;
private bool runCalib; private bool runCalib;
private bool hasInputEvts = false;
public bool ShouldRunCalib() public bool ShouldRunCalib()
{ {
return runCalib; return runCalib;
@ -1090,6 +1091,8 @@ namespace DS4Windows
cState.CopyTo(pState); cState.CopyTo(pState);
if (hasInputEvts)
{
lock (eventQueueLock) lock (eventQueueLock)
{ {
Action tempAct = null; Action tempAct = null;
@ -1098,6 +1101,9 @@ namespace DS4Windows
tempAct = eventQueue.Dequeue(); tempAct = eventQueue.Dequeue();
tempAct.Invoke(); tempAct.Invoke();
} }
hasInputEvts = false;
}
} }
} }
} }
@ -1467,6 +1473,7 @@ namespace DS4Windows
lock (eventQueueLock) lock (eventQueueLock)
{ {
eventQueue.Enqueue(act); eventQueue.Enqueue(act);
hasInputEvts = true;
} }
} }