diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx index 3782ad405..f2b42af6b 100644 --- a/src/event/Loop.cxx +++ b/src/event/Loop.cxx @@ -269,8 +269,7 @@ void EventLoop::Run() noexcept { #ifdef HAVE_THREADED_EVENT_LOOP - if (thread.IsNull()) - thread = ThreadId::GetCurrent(); + assert(!thread.IsNull()); #endif assert(IsInside()); diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx index a904f15de..5163bcb70 100644 --- a/src/event/Loop.hxx +++ b/src/event/Loop.hxx @@ -147,6 +147,12 @@ public: explicit EventLoop(ThreadId _thread); EventLoop():EventLoop(ThreadId::GetCurrent()) {} + + void SetThread(ThreadId _thread) noexcept { + assert(thread.IsNull()); + + thread = _thread; + } #else EventLoop(); #endif diff --git a/src/event/Thread.cxx b/src/event/Thread.cxx index dc6299a6c..d756171c9 100644 --- a/src/event/Thread.cxx +++ b/src/event/Thread.cxx @@ -39,6 +39,8 @@ EventThread::Run() noexcept { SetThreadName(realtime ? "rtio" : "io"); + event_loop.SetThread(ThreadId::GetCurrent()); + if (realtime) { SetThreadTimerSlack(std::chrono::microseconds(10));