thread/Thread: use BoundMethod
This commit is contained in:
+3
-11
@@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user