event/Loop: add method SetThread()
Require to call it before calling Run(); remove the setter from Run(). This gives class EventThread more control over when it is initialized.
This commit is contained in:
parent
b2bf95009b
commit
63cc07b8a7
src/event
@ -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());
|
||||
|
@ -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
|
||||
|
@ -39,6 +39,8 @@ EventThread::Run() noexcept
|
||||
{
|
||||
SetThreadName(realtime ? "rtio" : "io");
|
||||
|
||||
event_loop.SetThread(ThreadId::GetCurrent());
|
||||
|
||||
if (realtime) {
|
||||
SetThreadTimerSlack(std::chrono::microseconds(10));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user