diff --git a/src/thread/thread.h b/src/thread/thread.h index 28c8b59988..ecfd655fb6 100644 --- a/src/thread/thread.h +++ b/src/thread/thread.h @@ -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. diff --git a/src/thread/thread_morphos.cpp b/src/thread/thread_morphos.cpp index 322a2ab534..259b0a56b1 100644 --- a/src/thread/thread_morphos.cpp +++ b/src/thread/thread_morphos.cpp @@ -199,5 +199,6 @@ private: void SetSelfAsMainThread() { } bool IsMainThread() { return false; } +bool IsNonMainThread() { return false; } int GetThreadName(char *str, const char *last) { return 0; } diff --git a/src/thread/thread_none.cpp b/src/thread/thread_none.cpp index 30f1adeb6a..175cf32015 100644 --- a/src/thread/thread_none.cpp +++ b/src/thread/thread_none.cpp @@ -37,5 +37,6 @@ public: void SetSelfAsMainThread() { } bool IsMainThread() { return true; } +bool IsNonMainThread() { return false; } int GetThreadName(char *str, const char *last) { return 0; } diff --git a/src/thread/thread_os2.cpp b/src/thread/thread_os2.cpp index c666bbced7..41ae19ab38 100644 --- a/src/thread/thread_os2.cpp +++ b/src/thread/thread_os2.cpp @@ -150,4 +150,6 @@ void SetSelfAsMainThread() { } bool IsMainThread() { return false; } +bool IsNonMainThread() { return false; } + int GetThreadName(char *str, const char *last) { return 0; } diff --git a/src/thread/thread_pthread.cpp b/src/thread/thread_pthread.cpp index f00ae0bb8f..a6aeb521f4 100644 --- a/src/thread/thread_pthread.cpp +++ b/src/thread/thread_pthread.cpp @@ -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__) diff --git a/src/thread/thread_win32.cpp b/src/thread/thread_win32.cpp index c7e13a775b..c7831040b0 100644 --- a/src/thread/thread_win32.cpp +++ b/src/thread/thread_win32.cpp @@ -185,6 +185,11 @@ bool IsMainThread() return main_thread_id == GetCurrentThreadId(); } +bool IsNonMainThread() +{ + return main_thread_id != GetCurrentThreadId(); +} + static std::map _thread_name_map; static ThreadMutex_Win32 _thread_name_map_mutex;