perfc 0.11.0
Loading...
Searching...
No Matches
perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type > Class Template Reference

With timestamp Partial specialization for non-void Clock type. More...

#include <perfc/counter.hpp>

Detailed Description

template<class T, class Clock>
class perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >

With timestamp Partial specialization for non-void Clock type.

Thread Safety
thread-safe – All operations are thread safe but not necessarily synchronized

Satisfies AtomicCounter requirements.

Template Parameters
Tcounter value type. Type requirements:
  • TriviallyCopyable
  • CopyConstructible
  • CopyAssignable
Clocka clock satisfying TrivialClock requirements.

Definition at line 364 of file counter.hpp.

Public Types

using ClockType = Clock
 
using TimePointType = typename ClockType::time_point
 
using ValueType = Timestamped<T, TimePointType>
 
using CounterType = std::atomic<ValueType>
 

Public Member Functions

 Counter () noexcept
 Construct with value-initialized T (T())
 
 Counter (T value) noexcept
 Initialze with a value using current time.
 
 Counter (ValueType value) noexcept
 Initialze with value and time.
 
 Counter (Counter const &)=delete
 
bool IsLockFree () const noexcept
 Query if operations are lock free.
 
void Store (T value, MemoryOrder order=MemoryOrder::Release) noexcept
 Stores provided value and with current time by querying clock.
 
void Store (ValueType value, MemoryOrder order=MemoryOrder::Release) noexcept
 Store value with provided timestamp in counter.
 
ValueType Load (MemoryOrder order=MemoryOrder::Acquire) const noexcept
 Load value and timestamp from counter.
 

Static Public Attributes

static constexpr bool IS_ALWAYS_LOCK_FREE = CounterType::is_always_lock_free
 Is true if counter is always lock free.
 

Related Symbols

(Note that these are not member symbols.)

enum  MemoryOrder
 Memory ordering constraints. More...
 

Member Typedef Documentation

◆ ClockType

template<class T, class Clock>
using perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::ClockType = Clock

Definition at line 366 of file counter.hpp.

◆ CounterType

template<class T, class Clock>
using perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::CounterType = std::atomic<ValueType>

Definition at line 369 of file counter.hpp.

◆ TimePointType

template<class T, class Clock>
using perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::TimePointType = typename ClockType::time_point

Definition at line 367 of file counter.hpp.

◆ ValueType

template<class T, class Clock>
using perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::ValueType = Timestamped<T, TimePointType>

Definition at line 368 of file counter.hpp.

Constructor & Destructor Documentation

◆ Counter() [1/4]

template<class T, class Clock>
perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Counter ( )
inlineexplicitnoexcept

Construct with value-initialized T (T())

Definition at line 379 of file counter.hpp.

◆ Counter() [2/4]

template<class T, class Clock>
perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Counter ( T value)
inlineexplicitnoexcept

Initialze with a value using current time.

Parameters
valueInitial value.

Definition at line 387 of file counter.hpp.

◆ Counter() [3/4]

template<class T, class Clock>
perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Counter ( ValueType value)
inlineexplicitnoexcept

Initialze with value and time.

Parameters
valueInitial value and timestamp.

Definition at line 395 of file counter.hpp.

◆ Counter() [4/4]

template<class T, class Clock>
perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Counter ( Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type > const & )
delete

Member Function Documentation

◆ IsLockFree()

template<class T, class Clock>
bool perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::IsLockFree ( ) const
inlinenoexcept

Query if operations are lock free.

Returns
true if operations are lock free.
false otherwise.

Definition at line 405 of file counter.hpp.

◆ Load()

template<class T, class Clock>
ValueType perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Load ( MemoryOrder order = MemoryOrder::Acquire) const
inlinenodiscardnoexcept

Load value and timestamp from counter.

Parameters
orderMemory order constraints.
Returns
Counter value with timestamp.

Definition at line 435 of file counter.hpp.

◆ Store() [1/2]

template<class T, class Clock>
void perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Store ( T value,
MemoryOrder order = MemoryOrder::Release )
inlinenoexcept

Stores provided value and with current time by querying clock.

Parameters
valueCounter value to store.
orderMemory order constraints.

Definition at line 415 of file counter.hpp.

◆ Store() [2/2]

template<class T, class Clock>
void perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::Store ( ValueType value,
MemoryOrder order = MemoryOrder::Release )
inlinenoexcept

Store value with provided timestamp in counter.

Parameters
valueCounter value and timestamp to store.
orderMemory order constraints.

Definition at line 425 of file counter.hpp.

Friends And Related Symbol Documentation

◆ MemoryOrder

enum MemoryOrder : std::underlying_type_t< std::memory_order >
related

Memory ordering constraints.

Definition at line 81 of file counter.hpp.

Member Data Documentation

◆ IS_ALWAYS_LOCK_FREE

template<class T, class Clock>
bool perfc::Counter< T, Clock, typename std::enable_if<!std::is_void< Clock >::value >::type >::IS_ALWAYS_LOCK_FREE = CounterType::is_always_lock_free
staticconstexpr

Is true if counter is always lock free.

Definition at line 374 of file counter.hpp.


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