diff --git a/client/Tracy.hpp b/client/Tracy.hpp index 8be36ea0..cc897b0b 100755 --- a/client/Tracy.hpp +++ b/client/Tracy.hpp @@ -11,8 +11,12 @@ #define FrameMark +#define TracyLockable( type, varname ) type varname; +#define LockableBase( type ) type + #else +#include "TracyLock.hpp" #include "TracyProfiler.hpp" #include "TracyScoped.hpp" @@ -24,6 +28,9 @@ #define FrameMark tracy::Profiler::FrameMark(); +#define TracyLockable( type, varname ) tracy::Lockable varname { [] () -> const tracy::SourceLocation* { static const tracy::SourceLocation srcloc { #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() }; +#define LockableBase( type ) tracy::Lockable + #endif #endif diff --git a/client/TracyLock.hpp b/client/TracyLock.hpp new file mode 100755 index 00000000..6b1215e8 --- /dev/null +++ b/client/TracyLock.hpp @@ -0,0 +1,41 @@ +#ifndef __TRACYLOCK_HPP__ +#define __TRACYLOCK_HPP__ + +#include "TracyProfiler.hpp" + +namespace tracy +{ + +template +class Lockable +{ +public: + Lockable( const SourceLocation* srcloc ) + { + } + + Lockable( const Lockable& ) = delete; + Lockable& operator=( const Lockable& ) = delete; + + void lock() + { + m_lockable.lock(); + } + + void unlock() + { + m_lockable.unlock(); + } + + bool try_lock() + { + return m_lockable.try_lock(); + } + +private: + T m_lockable; +}; + +}; + +#endif