summaryrefslogtreecommitdiff
path: root/src/thread/Thread.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-02-10 22:43:55 +0100
committerMax Kellermann <max@musicpd.org>2017-02-10 22:43:55 +0100
commit5ba5bc8ba131de8a6c39139827e31c78f88c2ccc (patch)
treead7397cc172512237c672e59183898cb5e4f0f06 /src/thread/Thread.cxx
parent82c66ce0789a3d26a2c2c504cc431905f461f927 (diff)
thread/Thread: move code to Run()
Diffstat (limited to 'src/thread/Thread.cxx')
-rw-r--r--src/thread/Thread.cxx36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/thread/Thread.cxx b/src/thread/Thread.cxx
index 0042ad140..bdb7021fe 100644
--- a/src/thread/Thread.cxx
+++ b/src/thread/Thread.cxx
@@ -74,6 +74,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
@@ -81,7 +101,7 @@ Thread::ThreadProc(LPVOID ctx)
{
Thread &thread = *(Thread *)ctx;
- thread.f(thread.ctx);
+ thread.Run();
return 0;
}
@@ -92,19 +112,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;
}