event/Loop: use std::atomic_bool for the "quit" variable

Fixes thread sanitizer warnings.
This commit is contained in:
Max Kellermann 2017-12-22 11:04:24 +01:00
parent 5d6a8b3840
commit f8bb66b4e0
2 changed files with 4 additions and 4 deletions

View File

@ -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();
}

View File

@ -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