Lockable wrapper.

This commit is contained in:
Bartosz Taudul 2017-10-04 15:41:02 +02:00
parent 740a132f56
commit a3ef369a56
2 changed files with 48 additions and 0 deletions

View File

@ -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<type> varname { [] () -> const tracy::SourceLocation* { static const tracy::SourceLocation srcloc { #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() };
#define LockableBase( type ) tracy::Lockable<type>
#endif
#endif

41
client/TracyLock.hpp Executable file
View File

@ -0,0 +1,41 @@
#ifndef __TRACYLOCK_HPP__
#define __TRACYLOCK_HPP__
#include "TracyProfiler.hpp"
namespace tracy
{
template<class T>
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