event/Loop: use std::atomic_bool for the "quit" variable
Fixes thread sanitizer warnings.
This commit is contained in:
parent
5d6a8b3840
commit
f8bb66b4e0
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user