From b0f94f6b4564e695e9c5f3d6d797fdbea2fe367b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 22 Sep 2017 01:11:14 +0200 Subject: [PATCH] Add threading helpers. --- client/TracyThread.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 client/TracyThread.hpp diff --git a/client/TracyThread.hpp b/client/TracyThread.hpp new file mode 100755 index 00000000..4aac0d46 --- /dev/null +++ b/client/TracyThread.hpp @@ -0,0 +1,29 @@ +#ifndef __TRACYTHREAD_HPP__ +#define __TRACYTHREAD_HPP__ + +#include +#include + +#ifdef _MSC_VER +#include +#else +#include +#endif + +namespace tracy +{ + + static inline uint64_t GetThreadHandle() + { +#ifdef _MSC_VER + static_assert( sizeof( decltype( GetCurrentThreadId() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); + return uint64_t( GetCurrentThreadId() ); +#else + static_assert( sizeof( decltype( pthread_self() ) ) <= sizeof( uint64_t ), "Thread handle too big to fit in protocol" ); + return uint64_t( pthread_self() ); +#endif + } + +} + +#endif