thread/Thread: use BoundMethod

This commit is contained in:
Max Kellermann
2017-02-10 22:41:11 +01:00
parent 5ba5bc8ba1
commit 781487c4dd
19 changed files with 94 additions and 124 deletions
+3 -11
View File
@@ -26,7 +26,7 @@ EventThread::Start()
{
assert(!thread.IsDefined());
thread.Start(ThreadFunc, this);
thread.Start();
}
void
@@ -39,17 +39,9 @@ EventThread::Stop()
}
void
EventThread::ThreadFunc()
EventThread::Run()
{
SetThreadName("io");
event_loop.Run();
};
void
EventThread::ThreadFunc(void *arg)
{
auto &et = *(EventThread *)arg;
et.ThreadFunc();
};
}
+4 -2
View File
@@ -33,6 +33,9 @@ class EventThread final {
Thread thread;
public:
EventThread()
:thread(BIND_THIS_METHOD(Run)) {}
~EventThread() {
Stop();
}
@@ -55,8 +58,7 @@ public:
void Stop();
private:
void ThreadFunc();
static void ThreadFunc(void *arg);
void Run();
};
#endif /* MAIN_NOTIFY_H */