diff --git a/README.md b/README.md index 6fdb568d..c8d6cc01 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Tracy can collect and display lock interactions in threads. ![](doc/locks.png) -To mark a lock (mutex) for event reporting, use the `TracyLockable( type, varname )` macro. Note that the lock must implement a [Lockable concept](http://en.cppreference.com/w/cpp/concept/Lockable) (i.e. there's no support for timed mutices). For a concrete example, you would replace the line `std::mutex m_lock` with `TracyLockable( std::mutex, m_lock )`. +To mark a lock (mutex) for event reporting, use the `TracyLockable( type, varname )` macro. Note that the lock must implement a [Lockable concept](http://en.cppreference.com/w/cpp/concept/Lockable) (i.e. there's no support for timed mutices). For a concrete example, you would replace the line `std::mutex m_lock` with `TracyLockable( std::mutex, m_lock )`. You may use `TracyLockableN( type, varname, description )` to provide a custom lock name. The standard `std::lock_guard` and `std::unique_lock` wrappers should use the `LockableBase( type )` macro for their template parameter (unless you're using C++17, with improved template argument deduction). For example, `std::lock_guard lock( m_lock )`. diff --git a/client/Tracy.hpp b/client/Tracy.hpp index 2286561c..05caf9e4 100644 --- a/client/Tracy.hpp +++ b/client/Tracy.hpp @@ -12,6 +12,7 @@ #define FrameMark #define TracyLockable( type, varname ) type varname; +#define TracyLockableN( type, varname, desc ) type varname; #define LockableBase( type ) type #define LockMark(x) @@ -30,6 +31,7 @@ #define FrameMark tracy::Profiler::FrameMark(); #define TracyLockable( type, varname ) tracy::Lockable varname { [] () -> const tracy::SourceLocation* { static const tracy::SourceLocation srcloc { #type " " #varname, __FILE__, __LINE__, 0 }; return &srcloc; }() }; +#define TracyLockableN( type, varname, desc ) tracy::Lockable varname { [] () -> const tracy::SourceLocation* { static const tracy::SourceLocation srcloc { desc, __FILE__, __LINE__, 0 }; return &srcloc; }() }; #define LockableBase( type ) tracy::Lockable #define LockMark( varname ) static const tracy::SourceLocation __tracy_lock_location_##varname { __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; varname.Mark( &__tracy_lock_location_##varname );