Add method to get whether current thread is non-main
This commit is contained in:
@@ -133,6 +133,11 @@ void SetSelfAsMainThread();
|
||||
*/
|
||||
bool IsMainThread();
|
||||
|
||||
/**
|
||||
* @return true if the current thread definitely a "non-main" thread. If in doubt returns false.
|
||||
*/
|
||||
bool IsNonMainThread();
|
||||
|
||||
/**
|
||||
* Get the name of the current thread, if any.
|
||||
* @param str The start of the buffer.
|
||||
|
@@ -199,5 +199,6 @@ private:
|
||||
void SetSelfAsMainThread() { }
|
||||
|
||||
bool IsMainThread() { return false; }
|
||||
bool IsNonMainThread() { return false; }
|
||||
|
||||
int GetThreadName(char *str, const char *last) { return 0; }
|
||||
|
@@ -37,5 +37,6 @@ public:
|
||||
void SetSelfAsMainThread() { }
|
||||
|
||||
bool IsMainThread() { return true; }
|
||||
bool IsNonMainThread() { return false; }
|
||||
|
||||
int GetThreadName(char *str, const char *last) { return 0; }
|
||||
|
@@ -150,4 +150,6 @@ void SetSelfAsMainThread() { }
|
||||
|
||||
bool IsMainThread() { return false; }
|
||||
|
||||
bool IsNonMainThread() { return false; }
|
||||
|
||||
int GetThreadName(char *str, const char *last) { return 0; }
|
||||
|
@@ -203,6 +203,11 @@ bool IsMainThread()
|
||||
return main_thread == pthread_self();
|
||||
}
|
||||
|
||||
bool IsNonMainThread()
|
||||
{
|
||||
return main_thread != pthread_self();
|
||||
}
|
||||
|
||||
int GetThreadName(char *str, const char *last)
|
||||
{
|
||||
#if defined(__GLIBC__)
|
||||
|
@@ -185,6 +185,11 @@ bool IsMainThread()
|
||||
return main_thread_id == GetCurrentThreadId();
|
||||
}
|
||||
|
||||
bool IsNonMainThread()
|
||||
{
|
||||
return main_thread_id != GetCurrentThreadId();
|
||||
}
|
||||
|
||||
static std::map<uint, std::string> _thread_name_map;
|
||||
static ThreadMutex_Win32 _thread_name_map_mutex;
|
||||
|
||||
|
Reference in New Issue
Block a user