mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 19:14:20 +01:00
Use ReadWriteLockSlim instance instead of lock
This commit is contained in:
parent
79377ced7f
commit
ad7bbe7ea9
@ -71,8 +71,8 @@ namespace DS4Windows
|
||||
private bool running;
|
||||
private byte[] recvBuffer = new byte[1024];
|
||||
private SocketAsyncEventArgs[] argsList;
|
||||
private volatile int listInd = 0;
|
||||
private object poolLock = new object();
|
||||
private int listInd = 0;
|
||||
private ReaderWriterLockSlim poolLock = new ReaderWriterLockSlim();
|
||||
|
||||
public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta);
|
||||
|
||||
@ -185,11 +185,10 @@ namespace DS4Windows
|
||||
|
||||
//try { udpSock.SendTo(packetData, clientEP); }
|
||||
int temp = 0;
|
||||
lock (poolLock)
|
||||
{
|
||||
listInd = ++listInd % 20;
|
||||
temp = listInd;
|
||||
}
|
||||
poolLock.EnterWriteLock();
|
||||
listInd = ++listInd % 20;
|
||||
temp = listInd;
|
||||
poolLock.ExitWriteLock();
|
||||
|
||||
SocketAsyncEventArgs args = argsList[temp];
|
||||
args.RemoteEndPoint = clientEP;
|
||||
@ -651,11 +650,10 @@ namespace DS4Windows
|
||||
{
|
||||
//try { udpSock.SendTo(outputData, cl); }
|
||||
int temp = 0;
|
||||
lock (poolLock)
|
||||
{
|
||||
listInd = ++listInd % 20;
|
||||
temp = listInd;
|
||||
}
|
||||
poolLock.EnterWriteLock();
|
||||
listInd = ++listInd % 20;
|
||||
temp = listInd;
|
||||
poolLock.ExitWriteLock();
|
||||
|
||||
SocketAsyncEventArgs args = argsList[temp];
|
||||
args.RemoteEndPoint = cl;
|
||||
|
Loading…
Reference in New Issue
Block a user