summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-12-22 11:04:24 +0100
committerMax Kellermann <max@musicpd.org>2017-12-22 11:04:24 +0100
commitf8bb66b4e0e90438b15bbfdd73e54973cf2d6ad1 (patch)
tree2e7cff463a08e0350d9119ae7f17861da5aab4dd /src
parent5d6a8b384004e4ceaebc933973319d6a5e20ccea (diff)
event/Loop: use std::atomic_bool for the "quit" variable
Fixes thread sanitizer warnings.
Diffstat (limited to 'src')
-rw-r--r--src/event/Loop.cxx5
-rw-r--r--src/event/Loop.hxx3
2 files changed, 4 insertions, 4 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index 9bfeb9e9e..af488b899 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -25,7 +25,7 @@
#include "util/ScopeExit.hxx"
EventLoop::EventLoop(ThreadId _thread)
- :SocketMonitor(*this), thread(_thread)
+ :SocketMonitor(*this), quit(false), thread(_thread)
{
SocketMonitor::Open(SocketDescriptor(wake_fd.Get()));
}
@@ -39,10 +39,9 @@ EventLoop::~EventLoop()
void
EventLoop::Break()
{
- if (quit)
+ if (quit.exchange(true))
return;
- quit = true;
wake_fd.Write();
}
diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx
index 7b9ec69e4..1d516020d 100644
--- a/src/event/Loop.hxx
+++ b/src/event/Loop.hxx
@@ -36,6 +36,7 @@
#include <boost/intrusive/list.hpp>
#include <chrono>
+#include <atomic>
#include <assert.h>
@@ -85,7 +86,7 @@ class EventLoop final : SocketMonitor
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
- bool quit = false;
+ std::atomic_bool quit;
/**
* True when the object has been modified and another check is