mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-01-12 08:19:13 +01:00
Replace old lock with ReaderWriterLockSlim instance
This commit is contained in:
parent
f828eb888c
commit
a8c722d604
@ -2,10 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using static DS4Windows.Global;
|
||||
|
||||
|
||||
namespace DS4Windows
|
||||
{
|
||||
public class Mapping
|
||||
@ -77,6 +79,8 @@ namespace DS4Windows
|
||||
new Queue<ControlToXInput>(), new Queue<ControlToXInput>()
|
||||
};
|
||||
|
||||
static ReaderWriterLockSlim syncStateLock = new ReaderWriterLockSlim();
|
||||
|
||||
public static SyntheticState globalState = new SyntheticState();
|
||||
public static SyntheticState[] deviceState = new SyntheticState[4]
|
||||
{ new SyntheticState(), new SyntheticState(), new SyntheticState(),
|
||||
@ -190,8 +194,8 @@ namespace DS4Windows
|
||||
public static void Commit(int device)
|
||||
{
|
||||
SyntheticState state = deviceState[device];
|
||||
lock (globalState)
|
||||
{
|
||||
syncStateLock.EnterWriteLock();
|
||||
|
||||
globalState.currentClicks.leftCount += state.currentClicks.leftCount - state.previousClicks.leftCount;
|
||||
globalState.currentClicks.middleCount += state.currentClicks.middleCount - state.previousClicks.middleCount;
|
||||
globalState.currentClicks.rightCount += state.currentClicks.rightCount - state.previousClicks.rightCount;
|
||||
@ -389,7 +393,8 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
globalState.SaveToPrevious(false);
|
||||
}
|
||||
|
||||
syncStateLock.ExitWriteLock();
|
||||
state.SaveToPrevious(true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user