mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Lockable wrapper.
This commit is contained in:
parent
740a132f56
commit
a3ef369a56
@ -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
41
client/TracyLock.hpp
Executable 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
|
Loading…
Reference in New Issue
Block a user