summaryrefslogtreecommitdiff
path: root/src/thread
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-02-10 22:43:55 +0100
committerMax Kellermann <max@musicpd.org>2018-01-07 17:20:26 +0100
commit752ff12c37741d7b2bc52619529dabb59e91a998 (patch)
tree3055071bbd2211eea5a4b74474b58f76414fdd22 /src/thread
parent4bb89b1755d115aba6f4411c5de627db8801af72 (diff)
thread/Thread: move code to Run()
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/Thread.cxx36
-rw-r--r--src/thread/Thread.hxx2
2 files changed, 24 insertions, 14 deletions
diff --git a/src/thread/Thread.cxx b/src/thread/Thread.cxx
index 06c2f4559..16d68dc23 100644
--- a/src/thread/Thread.cxx
+++ b/src/thread/Thread.cxx
@@ -76,6 +76,26 @@ Thread::Join()
#endif
}
+inline void
+Thread::Run()
+{
+#ifndef WIN32
+#ifndef NDEBUG
+ /* this works around a race condition that causes an assertion
+ failure due to IsInside() spuriously returning false right
+ after the thread has been created, and the calling thread
+ hasn't initialised "defined" yet */
+ defined = true;
+#endif
+#endif
+
+ f(ctx);
+
+#ifdef ANDROID
+ Java::DetachCurrentThread();
+#endif
+}
+
#ifdef _WIN32
DWORD WINAPI
@@ -83,7 +103,7 @@ Thread::ThreadProc(LPVOID ctx)
{
Thread &thread = *(Thread *)ctx;
- thread.f(thread.ctx);
+ thread.Run();
return 0;
}
@@ -94,19 +114,7 @@ Thread::ThreadProc(void *ctx)
{
Thread &thread = *(Thread *)ctx;
-#ifndef NDEBUG
- /* this works around a race condition that causes an assertion
- failure due to IsInside() spuriously returning false right
- after the thread has been created, and the calling thread
- hasn't initialised "defined" yet */
- thread.defined = true;
-#endif
-
- thread.f(thread.ctx);
-
-#ifdef ANDROID
- Java::DetachCurrentThread();
-#endif
+ thread.Run();
return nullptr;
}
diff --git a/src/thread/Thread.hxx b/src/thread/Thread.hxx
index 5d1bb6a8a..9a58614a7 100644
--- a/src/thread/Thread.hxx
+++ b/src/thread/Thread.hxx
@@ -93,6 +93,8 @@ public:
void Join();
private:
+ void Run();
+
#ifdef _WIN32
static DWORD WINAPI ThreadProc(LPVOID ctx);
#else