diff options
Diffstat (limited to 'sources/shiboken2/libshiboken/helper.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/helper.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sources/shiboken2/libshiboken/helper.cpp b/sources/shiboken2/libshiboken/helper.cpp index 472924723..e42daff07 100644 --- a/sources/shiboken2/libshiboken/helper.cpp +++ b/sources/shiboken2/libshiboken/helper.cpp @@ -41,6 +41,12 @@ #include "sbkstring.h" #include <stdarg.h> +#ifdef _WIN32 +# include <windows.h> +#else +# include <pthread.h> +#endif + namespace Shiboken { @@ -141,4 +147,24 @@ int warning(PyObject* category, int stacklevel, const char* format, ...) return result; } +ThreadId currentThreadId() +{ +#if defined(_WIN32) + return GetCurrentThreadId(); +#elif defined(__APPLE_CC__) + return reinterpret_cast<ThreadId>(pthread_self()); +#else + return pthread_self(); +#endif +} + +// Internal, used by init() from main thread +static ThreadId _mainThreadId{0}; +void _initMainThreadId() { _mainThreadId = currentThreadId(); } + +ThreadId mainThreadId() +{ + return _mainThreadId; +} + } // namespace Shiboken |