KiCad PCB EDA Suite
PROF_COUNTER Class Reference

A thread-safe event counter. More...

#include <profile.h>

Public Member Functions

 PROF_COUNTER ()
 
 PROF_COUNTER (const std::string &aName)
 
unsigned long long Count () const
 
void Reset ()
 
unsigned long long operator++ (int)
 
void Show (std::ostream &aStream=std::cerr)
 

Private Attributes

std::string m_name
 
std::atomic_ullong m_count
 

Detailed Description

A thread-safe event counter.

Definition at line 225 of file profile.h.

Constructor & Destructor Documentation

◆ PROF_COUNTER() [1/2]

PROF_COUNTER::PROF_COUNTER ( )
inline

Definition at line 228 of file profile.h.

228 :
229 m_name( "Anonymous" ),
230 m_count( 0 )
231 {
232 }
std::atomic_ullong m_count
Definition: profile.h:266
std::string m_name
Definition: profile.h:265

◆ PROF_COUNTER() [2/2]

PROF_COUNTER::PROF_COUNTER ( const std::string &  aName)
inline

Definition at line 234 of file profile.h.

234 :
235 m_name( aName ),
236 m_count( 0 )
237 {
238 }

Member Function Documentation

◆ Count()

unsigned long long PROF_COUNTER::Count ( ) const
inline

Definition at line 240 of file profile.h.

241 {
242 return m_count.load();
243 }

References m_count.

◆ operator++()

unsigned long long PROF_COUNTER::operator++ ( int  )
inline

Definition at line 250 of file profile.h.

251 {
252 return m_count++;
253 }

References m_count.

◆ Reset()

void PROF_COUNTER::Reset ( )
inline

Definition at line 245 of file profile.h.

246 {
247 m_count.store( 0 );
248 }

References m_count.

◆ Show()

void PROF_COUNTER::Show ( std::ostream &  aStream = std::cerr)
inline

Definition at line 255 of file profile.h.

256 {
257 if( m_name.size() )
258 aStream << m_name << ": ";
259
260 aStream << m_count.load();
261 aStream << std::endl;
262 }

References m_count, and m_name.

Member Data Documentation

◆ m_count

std::atomic_ullong PROF_COUNTER::m_count
private

Definition at line 266 of file profile.h.

Referenced by Count(), operator++(), Reset(), and Show().

◆ m_name

std::string PROF_COUNTER::m_name
private

Definition at line 265 of file profile.h.

Referenced by Show().


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