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.
This commit is contained in:
parent
cd0e92878f
commit
7f9a2f8adb
@ -23,6 +23,7 @@
|
|||||||
#include "SocketMonitor.hxx"
|
#include "SocketMonitor.hxx"
|
||||||
#include "IdleMonitor.hxx"
|
#include "IdleMonitor.hxx"
|
||||||
#include "DeferredMonitor.hxx"
|
#include "DeferredMonitor.hxx"
|
||||||
|
#include "util/ScopeExit.hxx"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -30,17 +31,12 @@ EventLoop::EventLoop()
|
|||||||
:SocketMonitor(*this)
|
:SocketMonitor(*this)
|
||||||
{
|
{
|
||||||
SocketMonitor::Open(SocketDescriptor(wake_fd.Get()));
|
SocketMonitor::Open(SocketDescriptor(wake_fd.Get()));
|
||||||
SocketMonitor::Schedule(SocketMonitor::READ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventLoop::~EventLoop()
|
EventLoop::~EventLoop()
|
||||||
{
|
{
|
||||||
assert(idle.empty());
|
assert(idle.empty());
|
||||||
assert(timers.empty());
|
assert(timers.empty());
|
||||||
|
|
||||||
/* this is necessary to get a well-defined destruction
|
|
||||||
order */
|
|
||||||
SocketMonitor::Cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -144,6 +140,9 @@ EventLoop::Run()
|
|||||||
assert(!quit);
|
assert(!quit);
|
||||||
assert(busy);
|
assert(busy);
|
||||||
|
|
||||||
|
SocketMonitor::Schedule(SocketMonitor::READ);
|
||||||
|
AtScopeExit(this) { SocketMonitor::Cancel(); };
|
||||||
|
|
||||||
do {
|
do {
|
||||||
now = std::chrono::steady_clock::now();
|
now = std::chrono::steady_clock::now();
|
||||||
again = false;
|
again = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user