mn::basic_safe_counter< T, TLOCK > Class Template Reference

safe counter is a base of thread saftly counter More...

#include <mn_safecounter.hpp>

Public Types

using value_type = T
 
using self_type = basic_safe_counter< T, TLOCK >
 
using lock_type = TLOCK
 
using lock_ptr_type = pointer::basic_lock_ptr< T, TLOCK >
 

Public Member Functions

 basic_safe_counter ()
 Construct a new basic safe counter object. More...
 
 basic_safe_counter (value_type start)
 Construct a new basic safe counter object. More...
 
self_typeoperator++ ()
 thread saftly increment operator More...
 
self_typeoperator-- ()
 thread saftly decrement operator More...
 
value_type count ()
 get the current count More...
 

Protected Attributes

lock_type m_lockObject
 
volatile value_type m_iCount
 

Detailed Description

template<typename T, class TLOCK>
class mn::basic_safe_counter< T, TLOCK >

safe counter is a base of thread saftly counter

Member Typedef Documentation

◆ lock_ptr_type

template<typename T , class TLOCK >
using mn::basic_safe_counter< T, TLOCK >::lock_ptr_type = pointer::basic_lock_ptr<T, TLOCK>

◆ lock_type

template<typename T , class TLOCK >
using mn::basic_safe_counter< T, TLOCK >::lock_type = TLOCK

◆ self_type

template<typename T , class TLOCK >
using mn::basic_safe_counter< T, TLOCK >::self_type = basic_safe_counter<T, TLOCK>

◆ value_type

template<typename T , class TLOCK >
using mn::basic_safe_counter< T, TLOCK >::value_type = T

Constructor & Destructor Documentation

◆ basic_safe_counter() [1/2]

template<typename T , class TLOCK >
mn::basic_safe_counter< T, TLOCK >::basic_safe_counter ( )
inline

Construct a new basic safe counter object.

◆ basic_safe_counter() [2/2]

template<typename T , class TLOCK >
mn::basic_safe_counter< T, TLOCK >::basic_safe_counter ( value_type  start)
inlineexplicit

Construct a new basic safe counter object.

Parameters
startStart value of this counter

Member Function Documentation

◆ count()

template<typename T , class TLOCK >
value_type mn::basic_safe_counter< T, TLOCK >::count ( )
inline

get the current count

◆ operator++()

template<typename T , class TLOCK >
self_type& mn::basic_safe_counter< T, TLOCK >::operator++ ( void  )
inline

thread saftly increment operator

◆ operator--()

template<typename T , class TLOCK >
self_type& mn::basic_safe_counter< T, TLOCK >::operator-- ( )
inline

thread saftly decrement operator

Member Data Documentation

◆ m_iCount

template<typename T , class TLOCK >
volatile value_type mn::basic_safe_counter< T, TLOCK >::m_iCount
protected

◆ m_lockObject

template<typename T , class TLOCK >
lock_type mn::basic_safe_counter< T, TLOCK >::m_lockObject
protected

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