Switch to using QAtomicInc instead of "volatile" flags in more places.
This commit is contained in:
parent
6d6c969339
commit
c3dab4d642
@ -53,19 +53,18 @@ IPCSendThread::IPCSendThread(MUtils::IPCChannel *const ipc, const quint32 &comma
|
||||
:
|
||||
m_ipc(ipc), m_command(command), m_message(message)
|
||||
{
|
||||
m_result = false;
|
||||
}
|
||||
|
||||
void IPCSendThread::run(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_result = m_ipc->send(m_command, 0, QStringList() << m_message);
|
||||
m_result.fetchAndStoreOrdered(m_ipc->send(m_command, 0, QStringList() << m_message) ? 1 : 0);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
qWarning("Exception in IPC receive thread!");
|
||||
m_result = false;
|
||||
m_result.fetchAndStoreOrdered(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +77,6 @@ IPCReceiveThread::IPCReceiveThread(MUtils::IPCChannel *const ipc)
|
||||
:
|
||||
m_ipc(ipc)
|
||||
{
|
||||
m_stopped = false;
|
||||
}
|
||||
|
||||
void IPCReceiveThread::run(void)
|
||||
@ -111,9 +109,8 @@ void IPCReceiveThread::receiveLoop(void)
|
||||
|
||||
void IPCReceiveThread::stop(void)
|
||||
{
|
||||
if(!m_stopped)
|
||||
if(m_stopped.testAndSetOrdered(0, 1))
|
||||
{
|
||||
m_stopped = true;
|
||||
IPC::sendAsync(m_ipc, IPC::COMMAND_NONE, "exit");
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
virtual void run(void);
|
||||
|
||||
private:
|
||||
volatile bool m_result;
|
||||
QAtomicInt m_result;
|
||||
MUtils::IPCChannel *const m_ipc;
|
||||
const quint32 m_command;
|
||||
const QString m_message;
|
||||
@ -63,7 +63,7 @@ signals:
|
||||
|
||||
private:
|
||||
void receiveLoop(void);
|
||||
volatile bool m_stopped;
|
||||
QAtomicInt m_stopped;
|
||||
MUtils::IPCChannel *const m_ipc;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user