From 8d694d5205fa6a8444aab607cfc957052bc72ae4 Mon Sep 17 00:00:00 2001 From: peak3d Date: Mon, 4 Feb 2019 14:43:38 +0100 Subject: [PATCH] [Threads] revert #15263, log tid instead posix thread --- xbmc/threads/Thread.cpp | 2 +- xbmc/threads/Thread.h | 1 + xbmc/threads/platform/pthreads/ThreadImpl.cpp | 13 +++++++------ xbmc/threads/platform/win/ThreadImpl.cpp | 5 +++++ xbmc/utils/log.cpp | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/xbmc/threads/Thread.cpp b/xbmc/threads/Thread.cpp index cc9ef7eb52eb0..00ea6c2c8122a 100644 --- a/xbmc/threads/Thread.cpp +++ b/xbmc/threads/Thread.cpp @@ -103,7 +103,7 @@ THREADFUNC CThread::staticThread(void* data) } name = pThread->m_ThreadName; - id = pThread->m_ThreadId; + id = GetDisplayThreadId(pThread->m_ThreadId); autodelete = pThread->m_bAutoDelete; pThread->SetThreadInfo(); diff --git a/xbmc/threads/Thread.h b/xbmc/threads/Thread.h index ed3b1ad5717d6..c9e584f973da8 100644 --- a/xbmc/threads/Thread.h +++ b/xbmc/threads/Thread.h @@ -61,6 +61,7 @@ class CThread static bool IsCurrentThread(const ThreadIdentifier tid); static ThreadIdentifier GetCurrentThreadId(); + static ThreadIdentifier GetDisplayThreadId(const ThreadIdentifier tid); static CThread* GetCurrentThread(); virtual void OnException(){} // signal termination handler diff --git a/xbmc/threads/platform/pthreads/ThreadImpl.cpp b/xbmc/threads/platform/pthreads/ThreadImpl.cpp index 222b685d7b2e1..4ad675eb4a243 100644 --- a/xbmc/threads/platform/pthreads/ThreadImpl.cpp +++ b/xbmc/threads/platform/pthreads/ThreadImpl.cpp @@ -115,21 +115,22 @@ void CThread::SetThreadInfo() } ThreadIdentifier CThread::GetCurrentThreadId() +{ + return pthread_self(); +} + +ThreadIdentifier CThread::GetDisplayThreadId(const ThreadIdentifier tid) { #if defined(TARGET_ANDROID) - return gettid(); + return pthread_gettid_np(tid); #else - return pthread_self(); + return tid; #endif } bool CThread::IsCurrentThread(const ThreadIdentifier tid) { -#if defined(TARGET_ANDROID) - return gettid() == tid; -#else return pthread_equal(pthread_self(), tid); -#endif } int CThread::GetMinPriority(void) diff --git a/xbmc/threads/platform/win/ThreadImpl.cpp b/xbmc/threads/platform/win/ThreadImpl.cpp index 5efb3cdaaeb84..c505f03fa6db1 100644 --- a/xbmc/threads/platform/win/ThreadImpl.cpp +++ b/xbmc/threads/platform/win/ThreadImpl.cpp @@ -70,6 +70,11 @@ ThreadIdentifier CThread::GetCurrentThreadId() return ::GetCurrentThreadId(); } +ThreadIdentifier CThread::GetDisplayThreadId(const ThreadIdentifier tid) +{ + return tid; +} + bool CThread::IsCurrentThread(const ThreadIdentifier tid) { return (::GetCurrentThreadId() == tid); diff --git a/xbmc/utils/log.cpp b/xbmc/utils/log.cpp index 1f8cfdf0f7f0d..72b326a5e3756 100644 --- a/xbmc/utils/log.cpp +++ b/xbmc/utils/log.cpp @@ -203,7 +203,7 @@ bool CLog::WriteLogString(int logLevel, const std::string& logString) minute, second, static_cast(millisecond), - (uint64_t)CThread::GetCurrentThreadId(), + (uint64_t)CThread::GetDisplayThreadId(CThread::GetCurrentThreadId()), levelNames[logLevel]) + strData; return g_logState.m_platform.WriteStringToLog(strData);