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, true > Struct Template Reference

#include "timemory/trace.hpp"

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

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 bool & get_global ()
 

Detailed Description

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

Definition at line 138 of file trace.hpp.

Constructor & Destructor Documentation

◆ lock() [1/3]

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

Definition at line 140 of file trace.hpp.

141 : m_value(!get_global())
142 {
143 if(m_value)
144 get_global() = true;
145 }
static bool & get_global()
Definition: trace.hpp:187

◆ ~lock()

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

Definition at line 147 of file trace.hpp.

148 {
149 if(m_value)
150 get_global() = false;
151 }

◆ lock() [2/3]

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

◆ lock() [3/3]

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

Member Function Documentation

◆ acquire()

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

Definition at line 173 of file trace.hpp.

174 {
175 int64_t itr = 0;
176 while(!m_value)
177 {
178 if((m_value = !get_global()))
179 get_global() = true;
181 break;
182 }
183 return m_value;
184 }
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320

References std::max().

◆ get_global()

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

Definition at line 187 of file trace.hpp.

188 {
189 static thread_local bool _instance = false;
190 return _instance;
191 }

◆ get_local()

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

Definition at line 161 of file trace.hpp.

161{ return m_value; }

◆ operator bool()

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

Definition at line 159 of file trace.hpp.

159{ return m_value; }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ release()

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

Definition at line 163 of file trace.hpp.

164 {
165 if(!m_value)
166 return false;
167
168 get_global() = false;
169 m_value = false;
170 return true;
171 }

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