carb::profiler::ProfiledMutex

Defined in carb/profiler/Profile.h

template<class Mutex>
class ProfiledMutex

Wrapper to add automatic profiling to a mutex.

Subclassed by carb::profiler::ProfiledSharedMutex< Mutex >

Public Functions

inline ProfiledMutex(const uint64_t profileMask, const char *name)

Constructor.

Parameters
  • profileMask – The mask used to determine if events from this mutex are captured.

  • name – The name of the mutex

inline ProfiledMutex(const carb::profiler::Channel &channel, const char *name)

Constructor.

Parameters
  • channel – The profiling channel used to determine if events from this mutex are captured.

  • name – The name of the mutex

inline ~ProfiledMutex()

Destructor.

inline void lock()

Locks the underlying mutex and reports the event to the profiler.

inline bool try_lock()

Attempts a lock on the underlying mutex and reports the event to the profiler if successful.

Returns

true if successfully locked; false otherwise.

inline void unlock()

Unlocks the underlying mutex and reports the event to the profiler.

inline Mutex &getMutex()

Returns a reference to the underlying mutex.

Returns

a reference to the underlying mutex.

inline const Mutex &getMutex() const

Returns a reference to the underlying mutex.

Returns

a reference to the underlying mutex.

Protected Functions

inline ProfiledMutex(const uint64_t profileMask, bool isSharedMutex, const char *name)

Protected Constructor.

Parameters
  • profileMask – The mask used to determine if events from this mutex are captured.

  • isSharedMutex – A boolean representing whether *this represents a shared mutex.

  • name – The name of the mutex

inline ProfiledMutex(const carb::profiler::Channel &channel, bool isSharedMutex, const char *name)

Protected Constructor.

Parameters
  • channel – The channel used to determine if events from this mutex are captured.

  • isSharedMutex – A boolean representing whether *this represents a shared mutex.

  • name – The name of the mutex

Protected Attributes

Mutex m_mutex

The underlying mutex instance.

LockableId m_lockableId

The lockable ID as returned by carb::profiler::IProfiler::createLockable()