mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-03-10 18:28:02 +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 bool running;
|
||||||
private byte[] recvBuffer = new byte[1024];
|
private byte[] recvBuffer = new byte[1024];
|
||||||
private SocketAsyncEventArgs[] argsList;
|
private SocketAsyncEventArgs[] argsList;
|
||||||
private volatile int listInd = 0;
|
private int listInd = 0;
|
||||||
private object poolLock = new object();
|
private ReaderWriterLockSlim poolLock = new ReaderWriterLockSlim();
|
||||||
|
|
||||||
public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta);
|
public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta);
|
||||||
|
|
||||||
@ -185,11 +185,10 @@ namespace DS4Windows
|
|||||||
|
|
||||||
//try { udpSock.SendTo(packetData, clientEP); }
|
//try { udpSock.SendTo(packetData, clientEP); }
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
lock (poolLock)
|
poolLock.EnterWriteLock();
|
||||||
{
|
listInd = ++listInd % 20;
|
||||||
listInd = ++listInd % 20;
|
temp = listInd;
|
||||||
temp = listInd;
|
poolLock.ExitWriteLock();
|
||||||
}
|
|
||||||
|
|
||||||
SocketAsyncEventArgs args = argsList[temp];
|
SocketAsyncEventArgs args = argsList[temp];
|
||||||
args.RemoteEndPoint = clientEP;
|
args.RemoteEndPoint = clientEP;
|
||||||
@ -651,11 +650,10 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
//try { udpSock.SendTo(outputData, cl); }
|
//try { udpSock.SendTo(outputData, cl); }
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
lock (poolLock)
|
poolLock.EnterWriteLock();
|
||||||
{
|
listInd = ++listInd % 20;
|
||||||
listInd = ++listInd % 20;
|
temp = listInd;
|
||||||
temp = listInd;
|
poolLock.ExitWriteLock();
|
||||||
}
|
|
||||||
|
|
||||||
SocketAsyncEventArgs args = argsList[temp];
|
SocketAsyncEventArgs args = argsList[temp];
|
||||||
args.RemoteEndPoint = cl;
|
args.RemoteEndPoint = cl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user