diff options
author | Max Kellermann <max@musicpd.org> | 2017-08-18 18:08:06 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-08-18 18:08:06 +0200 |
commit | 7f9a2f8adbf7de339d1f2ddb0e7467303d339ed4 (patch) | |
tree | 977e9d227da12649935af5e2062246852bd4c065 /src | |
parent | cd0e92878f847cca73c1ea900cda0f3afee4d77c (diff) |
event/Loop: schedule and cancel the WakeFD in Run()
This is only needed while Run() is alive, and moving it there avoids
problems with thread-checking assertions.
Diffstat (limited to 'src')
-rw-r--r-- | src/event/Loop.cxx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index 93fdd0b1f..c74fa86c8 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -23,6 +23,7 @@ #include "SocketMonitor.hxx" #include "IdleMonitor.hxx" #include "DeferredMonitor.hxx" +#include "util/ScopeExit.hxx" #include <algorithm> @@ -30,17 +31,12 @@ EventLoop::EventLoop() :SocketMonitor(*this) { SocketMonitor::Open(SocketDescriptor(wake_fd.Get())); - SocketMonitor::Schedule(SocketMonitor::READ); } EventLoop::~EventLoop() { assert(idle.empty()); assert(timers.empty()); - - /* this is necessary to get a well-defined destruction - order */ - SocketMonitor::Cancel(); } void @@ -144,6 +140,9 @@ EventLoop::Run() assert(!quit); assert(busy); + SocketMonitor::Schedule(SocketMonitor::READ); + AtScopeExit(this) { SocketMonitor::Cancel(); }; + do { now = std::chrono::steady_clock::now(); again = false; |