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 2eef4e6716
commit 1f50bdb230
2 changed files with 6 additions and 3 deletions

View File

@ -27,7 +27,7 @@
#include <algorithm>
EventLoop::EventLoop()
:SocketMonitor(*this)
:SocketMonitor(*this), quit(false)
{
SocketMonitor::Open(wake_fd.Get());
SocketMonitor::Schedule(SocketMonitor::READ);
@ -46,7 +46,9 @@ EventLoop::~EventLoop()
void
EventLoop::Break()
{
quit = true;
if (quit.exchange(true))
return;
wake_fd.Write();
}

View File

@ -30,6 +30,7 @@
#include "SocketMonitor.hxx"
#include <chrono>
#include <atomic>
#include <list>
#include <set>
@ -82,7 +83,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