Corelink CPP Client
Corelink C++ client library
 
Loading...
Searching...
No Matches
corelink::utils::concurrent_counter< numeric_type > Class Template Reference

#include <concurrent_counter.hpp>

Public Types

typedef numeric_type counter_type
 Type of the counter.
 

Public Member Functions

 concurrent_counter ()
 Construct a new counter object. Initializes the counter with a.
 
 concurrent_counter (numeric_type upper_bound, numeric_type lower_bound)
 Construct a new counter object.
 
 concurrent_counter (numeric_type reset_value, numeric_type upper_bound, numeric_type lower_bound)
 Construct a new counter object.
 
 concurrent_counter (numeric_type initial_value, numeric_type reset_value, numeric_type upper_bound, numeric_type lower_bound)
 Construct a new counter object.
 
virtual ~concurrent_counter ()=default
 
std::atomic< numeric_type > & operator() ()
 
numeric_type operator++ (int32_t)
 overloaded post increment operator
 
numeric_type operator++ ()
 overloaded pre increment operator
 
numeric_type operator-- (int32_t)
 overloaded post decrement operator
 
numeric_type operator-- ()
 overloaded pre decrement operator
 
 operator numeric_type () const
 type conversion operator
 
void reset ()
 Returns the counter to its reset value.
 

Friends

std::ostream & operator<< (std::ostream &os, const concurrent_counter &rhs)
 overloaded ostream operator for capturing the counter value
 

Detailed Description

template<class numeric_type = uint32_t>
class corelink::utils::concurrent_counter< numeric_type >

Concurrent counter class

Template Parameters
numeric_typeintegral numeric type

Member Typedef Documentation

◆ counter_type

template<class numeric_type = uint32_t>
typedef numeric_type corelink::utils::concurrent_counter< numeric_type >::counter_type

Type of the counter.

Constructor & Destructor Documentation

◆ concurrent_counter() [1/4]

template<class numeric_type = uint32_t>
corelink::utils::concurrent_counter< numeric_type >::concurrent_counter ( )
inlineexplicit

Construct a new counter object. Initializes the counter with a.

  • Upper bound of max(numeric_type)
  • Lower bound of 0
  • Reset value of 0
  • Initial value of 0

◆ concurrent_counter() [2/4]

template<class numeric_type = uint32_t>
corelink::utils::concurrent_counter< numeric_type >::concurrent_counter ( numeric_type upper_bound,
numeric_type lower_bound )
inlineexplicit

Construct a new counter object.

Parameters
upper_boundupper bound of the counter variable after which the counter will be reset
lower_boundlower bound of the counter variable after which the counter will be reset

◆ concurrent_counter() [3/4]

template<class numeric_type = uint32_t>
corelink::utils::concurrent_counter< numeric_type >::concurrent_counter ( numeric_type reset_value,
numeric_type upper_bound,
numeric_type lower_bound )
inline

Construct a new counter object.

Parameters
reset_valuevalue to which the counter will be reset to
upper_boundupper bound of the counter variable after which the counter will be reset
lower_boundlower bound of the counter variable after which the counter will be reset

◆ concurrent_counter() [4/4]

template<class numeric_type = uint32_t>
corelink::utils::concurrent_counter< numeric_type >::concurrent_counter ( numeric_type initial_value,
numeric_type reset_value,
numeric_type upper_bound,
numeric_type lower_bound )
inline

Construct a new counter object.

Parameters
initial_valuethe initial value that will be loaded in to the counter at initialisation
reset_valuevalue to which the counter will be reset to
upper_boundupper bound of the counter variable after which the counter will be reset
lower_boundlower bound of the counter variable after which the counter will be reset

◆ ~concurrent_counter()

template<class numeric_type = uint32_t>
virtual corelink::utils::concurrent_counter< numeric_type >::~concurrent_counter ( )
virtualdefault

Member Function Documentation

◆ operator numeric_type()

template<class numeric_type = uint32_t>
corelink::utils::concurrent_counter< numeric_type >::operator numeric_type ( ) const
inlineexplicit

type conversion operator

Returns
the current counter value

◆ operator()()

template<class numeric_type = uint32_t>
std::atomic< numeric_type > & corelink::utils::concurrent_counter< numeric_type >::operator() ( )
inline

Get the underlying counter. Do not access

Returns
underlying counter instance

◆ operator++() [1/2]

template<class numeric_type = uint32_t>
numeric_type corelink::utils::concurrent_counter< numeric_type >::operator++ ( )
inline

overloaded pre increment operator

◆ operator++() [2/2]

template<class numeric_type = uint32_t>
numeric_type corelink::utils::concurrent_counter< numeric_type >::operator++ ( int32_t )
inline

overloaded post increment operator

◆ operator--() [1/2]

template<class numeric_type = uint32_t>
numeric_type corelink::utils::concurrent_counter< numeric_type >::operator-- ( )
inline

overloaded pre decrement operator

◆ operator--() [2/2]

template<class numeric_type = uint32_t>
numeric_type corelink::utils::concurrent_counter< numeric_type >::operator-- ( int32_t )
inline

overloaded post decrement operator

◆ reset()

template<class numeric_type = uint32_t>
void corelink::utils::concurrent_counter< numeric_type >::reset ( )
inline

Returns the counter to its reset value.

Friends And Related Symbol Documentation

◆ operator<<

template<class numeric_type = uint32_t>
std::ostream & operator<< ( std::ostream & os,
const concurrent_counter< numeric_type > & rhs )
friend

overloaded ostream operator for capturing the counter value

Parameters
osstd::ostream instance
rhsinstance of the counter class
Returns
std::ostream instance

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