Skip to content

Commit

Permalink
Merge pull request #15419 from peak3d/threads
Browse files Browse the repository at this point in the history
[Threads] revert #15263, log tid instead posix thread
  • Loading branch information
MartijnKaijser committed Feb 4, 2019
2 parents d8363ba + 8d694d5 commit ac68103
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion xbmc/threads/Thread.cpp
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions xbmc/threads/Thread.h
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions xbmc/threads/platform/pthreads/ThreadImpl.cpp
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions xbmc/threads/platform/win/ThreadImpl.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/utils/log.cpp
Expand Up @@ -203,7 +203,7 @@ bool CLog::WriteLogString(int logLevel, const std::string& logString)
minute,
second,
static_cast<int>(millisecond),
(uint64_t)CThread::GetCurrentThreadId(),
(uint64_t)CThread::GetDisplayThreadId(CThread::GetCurrentThreadId()),
levelNames[logLevel]) + strData;

return g_logState.m_platform.WriteStringToLog(strData);
Expand Down

0 comments on commit ac68103

Please sign in to comment.