Merge pull request #2528 from lioncash/volatile
EXI_DeviceEthernet: Convert a volatile bool to an atomic
This commit is contained in:
commit
175e0d1926
|
@ -22,7 +22,7 @@ bool CEXIETHERNET::Activate()
|
|||
return false;
|
||||
}
|
||||
|
||||
readEnabled = false;
|
||||
readEnabled.store(false);
|
||||
|
||||
INFO_LOG(SP1, "BBA initialized.");
|
||||
return true;
|
||||
|
@ -33,7 +33,7 @@ void CEXIETHERNET::Deactivate()
|
|||
close(fd);
|
||||
fd = -1;
|
||||
|
||||
readEnabled = false;
|
||||
readEnabled.store(false);
|
||||
if (readThread.joinable())
|
||||
readThread.join();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ static void ReadThreadHandler(CEXIETHERNET* self)
|
|||
{
|
||||
ERROR_LOG(SP1, "Failed to read from BBA, err=%d", readBytes);
|
||||
}
|
||||
else if (self->readEnabled)
|
||||
else if (self->readEnabled.load())
|
||||
{
|
||||
INFO_LOG(SP1, "Read data: %s", ArrayToString(self->mRecvBuffer, readBytes, 0x10).c_str());
|
||||
self->mRecvBufferLength = readBytes;
|
||||
|
@ -103,11 +103,11 @@ bool CEXIETHERNET::RecvStart()
|
|||
if (!readThread.joinable())
|
||||
RecvInit();
|
||||
|
||||
readEnabled = true;
|
||||
readEnabled.store(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStop()
|
||||
{
|
||||
readEnabled = false;
|
||||
readEnabled.store(false);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ bool CEXIETHERNET::Activate()
|
|||
}
|
||||
ioctl(fd, TUNSETNOCSUM, 1);
|
||||
|
||||
readEnabled = false;
|
||||
readEnabled.store(false);
|
||||
|
||||
INFO_LOG(SP1, "BBA initialized with associated tap %s", ifr.ifr_name);
|
||||
return true;
|
||||
|
@ -66,7 +66,7 @@ void CEXIETHERNET::Deactivate()
|
|||
close(fd);
|
||||
fd = -1;
|
||||
|
||||
readEnabled = false;
|
||||
readEnabled.store(false);
|
||||
if (readThread.joinable())
|
||||
readThread.join();
|
||||
#else
|
||||
|
@ -128,7 +128,7 @@ static void ReadThreadHandler(CEXIETHERNET* self)
|
|||
{
|
||||
ERROR_LOG(SP1, "Failed to read from BBA, err=%d", readBytes);
|
||||
}
|
||||
else if (self->readEnabled)
|
||||
else if (self->readEnabled.load())
|
||||
{
|
||||
INFO_LOG(SP1, "Read data: %s", ArrayToString(self->mRecvBuffer, readBytes, 0x10).c_str());
|
||||
self->mRecvBufferLength = readBytes;
|
||||
|
@ -154,7 +154,7 @@ bool CEXIETHERNET::RecvStart()
|
|||
if (!readThread.joinable())
|
||||
RecvInit();
|
||||
|
||||
readEnabled = true;
|
||||
readEnabled.store(true);
|
||||
return true;
|
||||
#else
|
||||
NOTIMPLEMENTED("RecvStart");
|
||||
|
@ -165,7 +165,7 @@ bool CEXIETHERNET::RecvStart()
|
|||
void CEXIETHERNET::RecvStop()
|
||||
{
|
||||
#ifdef __linux__
|
||||
readEnabled = false;
|
||||
readEnabled.store(false);
|
||||
#else
|
||||
NOTIMPLEMENTED("RecvStop");
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
@ -328,7 +330,7 @@ public:
|
|||
#elif defined(__linux__) || defined(__APPLE__)
|
||||
int fd;
|
||||
std::thread readThread;
|
||||
volatile bool readEnabled;
|
||||
std::atomic<bool> readEnabled;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue