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