timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::trace::lock< Tp, false > Struct Template Reference

#include "timemory/trace.hpp"

+ Collaboration diagram for tim::trace::lock< Tp, false >:

Public Member Functions

 lock ()
 
 ~lock ()
 
 lock (lock &&) noexcept=default
 
lockoperator= (lock &&) noexcept=default
 
 lock (const lock &)=delete
 
lockoperator= (const lock &)=delete
 
 operator bool () const
 
bool & get_local ()
 
bool release ()
 
bool acquire ()
 

Static Public Member Functions

static auto load ()
 
static auto exchange (bool _value)
 
static std::atomic< bool > & get_global ()
 

Detailed Description

template<typename Tp>
struct tim::trace::lock< Tp, false >

Definition at line 200 of file trace.hpp.

Constructor & Destructor Documentation

◆ lock() [1/3]

template<typename Tp >
tim::trace::lock< Tp, false >::lock ( )
inline

Definition at line 202 of file trace.hpp.

203 : m_value(exchange(true))
204 {}
static auto exchange(bool _value)
Definition: trace.hpp:247

◆ ~lock()

template<typename Tp >
tim::trace::lock< Tp, false >::~lock ( )
inline

Definition at line 206 of file trace.hpp.

207 {
208 if(m_value)
209 exchange(false);
210 }

◆ lock() [2/3]

template<typename Tp >
tim::trace::lock< Tp, false >::lock ( lock< Tp, false > &&  )
defaultnoexcept

◆ lock() [3/3]

template<typename Tp >
tim::trace::lock< Tp, false >::lock ( const lock< Tp, false > &  )
delete

Member Function Documentation

◆ acquire()

template<typename Tp >
bool tim::trace::lock< Tp, false >::acquire ( )
inline

Definition at line 231 of file trace.hpp.

232 {
233 int64_t itr = 0;
234 if(!m_value)
235 {
236 while(!(m_value = exchange(true)))
237 {
239 break;
240 }
241 }
242 return m_value;
243 }
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320

References std::max().

◆ exchange()

template<typename Tp >
static auto tim::trace::lock< Tp, false >::exchange ( bool  _value)
inlinestatic

Definition at line 247 of file trace.hpp.

248 {
249 auto _load = load();
250 if(_load == _value)
251 return false;
252 return get_global().compare_exchange_strong(_load, _value,
253 std::memory_order_relaxed);
254 }
static std::atomic< bool > & get_global()
Definition: trace.hpp:256

References tim::cereal::load().

◆ get_global()

template<typename Tp >
static std::atomic< bool > & tim::trace::lock< Tp, false >::get_global ( )
inlinestatic

Definition at line 256 of file trace.hpp.

257 {
258 static std::atomic<bool> _instance{ false };
259 return _instance;
260 }

◆ get_local()

template<typename Tp >
bool & tim::trace::lock< Tp, false >::get_local ( )
inline

Definition at line 220 of file trace.hpp.

220{ return m_value; }

◆ load()

template<typename Tp >
static auto tim::trace::lock< Tp, false >::load ( )
inlinestatic

Definition at line 246 of file trace.hpp.

246{ return get_global().load(std::memory_order_relaxed); }

◆ operator bool()

template<typename Tp >
tim::trace::lock< Tp, false >::operator bool ( ) const
inline

Definition at line 218 of file trace.hpp.

218{ return m_value; }

◆ operator=() [1/2]

template<typename Tp >
lock & tim::trace::lock< Tp, false >::operator= ( const lock< Tp, false > &  )
delete

◆ operator=() [2/2]

template<typename Tp >
lock & tim::trace::lock< Tp, false >::operator= ( lock< Tp, false > &&  )
defaultnoexcept

◆ release()

template<typename Tp >
bool tim::trace::lock< Tp, false >::release ( )
inline

Definition at line 222 of file trace.hpp.

223 {
224 if(!m_value)
225 return false;
226
227 m_value = exchange(false);
228 return true;
229 }

The documentation for this struct was generated from the following file: