libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT > Class Template Reference

A general-purpose, atomic counter class, similar to the atomic integer types in C++11 ch 29. More...

#include <atomic_counter.hpp>

Inheritance diagram for jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >:
[legend]
Collaboration diagram for jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >:
[legend]

Public Types

typedef sp_counter_itf_type< V > base_t
 
typedef LkT lock_traits
 
typedef lock_traits::recursive_critical_section_type atomic_t
 
typedef base_t::value_type value_type
 
- Public Types inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::sp_counter_itf_type< V >
typedef V value_type
 
typedef default_delete< sp_counter_itf_typedeleter_t
 The default deletion method for objects that inherit from this intrusively-counted type, which is just heap-deletion, if the objects are heap-allocated. More...
 

Public Member Functions

constexpr atomic_ctr_gen () noexcept(noexcept(value_type()) &&noexcept(atomic_t())) FORCE_INLINE
 
constexpr atomic_ctr_gen (const value_type v) noexcept(noexcept(value_type(std::declval< value_type >())) &&noexcept(atomic_t())) FORCE_INLINE
 
constexpr atomic_ctr_gen (const atomic_ctr_gen &) noexcept(false) FORCE_INLINE
 
template<class V1 >
constexpr atomic_ctr_gen (const atomic_ctr_gen< V1, LkT > &) noexcept(false) FORCE_INLINE
 
template<class V1 >
 atomic_ctr_gen (atomic_ctr_gen< V1, LkT > &&) noexcept(true) FORCE_INLINE
 
 ~atomic_ctr_gen () noexcept(true)
 
void swap (atomic_ctr_gen &rhs) noexcept(true) FORCE_INLINE
 
template<class V1 , class V2 = V1>
std::enable_if< std::is_pointer< V2 >::value, void >::type swap (atomic_ctr_gen< V1, LkT > &rhs) noexcept(true) FORCE_INLINE
 
template<class V1 , class V2 = V1>
std::enable_if< std::is_pointer< V2 >::value, void >::type __fastcall operator= (const atomic_ctr_gen< V1, LkT > &v) noexcept(true) FORCE_INLINE
 
void __fastcall operator= (const atomic_ctr_gen &) noexcept(true) FORCE_INLINE
 
void __fastcall operator= (const value_type &) noexcept(true) FORCE_INLINE
 
constexpr bool FORCE_INLINE sp_noop_ctr () const noexcept(true) override
 
constexpr value_type const &__fastcall get () const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator! () const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator== (const value_type) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator== (const atomic_ctr_gen &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator!= (const value_type) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator!= (const atomic_ctr_gen &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator< (const value_type) const noexcept(true) FORCE_INLINE override
 
constexpr bool __fastcall operator< (const atomic_ctr_gen &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator< (base_t const &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator> (const value_type) const noexcept(true) override
 
constexpr bool __fastcall operator> (const atomic_ctr_gen &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator> (base_t const &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator<= (const value_type) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator<= (const atomic_ctr_gen &) const noexcept(true) FORCE_INLINE
 
constexpr bool __fastcall operator>= (const value_type) const noexcept(true) override
 
constexpr bool __fastcall operator>= (const atomic_ctr_gen &) const noexcept(true) FORCE_INLINE
 
value_type __fastcall operator++ () noexcept(true) FORCE_INLINE
 
value_type __fastcall operator++ (int) noexcept(true) FORCE_INLINE
 
value_type __fastcall operator-- () noexcept(true) FORCE_INLINE
 
value_type __fastcall operator-- (int) noexcept(true) FORCE_INLINE
 
value_type __fastcall operator+= (const value_type) noexcept(true) FORCE_INLINE
 
value_type __fastcall operator+= (const atomic_ctr_gen &) noexcept(true) FORCE_INLINE
 
value_type __fastcall operator-= (const value_type) noexcept(true) FORCE_INLINE
 
value_type __fastcall operator-= (const atomic_ctr_gen &) noexcept(true) FORCE_INLINE
 
template<class V1 = value_type>
std::enable_if< std::is_pointer< V1 >::value, V1 >::type FORCE_INLINE operator-> () const noexcept(true)
 
template<class BinOp >
value_type __fastcall apply (typename BinOp::second_argument_type const &a, BinOp const &op) noexcept(noexcept(op.operator()(std::declval< value_type >(), std::declval< typename BinOp::second_argument_type >()))) FORCE_INLINE
 
template<class V1 >
value_type __fastcall apply (V1 const &a, std::plus< V1 > const &) noexcept(true) FORCE_INLINE
 
template<class V1 >
value_type __fastcall apply (V1 const &a, std::minus< V1 > const &) noexcept(true) FORCE_INLINE
 
bool compare_exchange_strong (value_type expected, value_type desired) noexcept(true) FORCE_INLINE
 
template<class V1 , class V2 = V1>
std::enable_if< std::is_pointer< V2 >::value, bool >::type compare_exchange_strong (value_type expected, V1 desired) noexcept(true) FORCE_INLINE
 
template<class Op >
atomic_ctr_gen assign (Op &&op) noexcept(true) FORCE_INLINE
 
template<class V1 , class V2 >
std::enable_if< std::is_pointer< V2 >::value, void >::type operator= (const atomic_ctr_gen< V1, LkT > &a) noexcept(true)
 
template<class BinOp >
atomic_ctr_gen< V, LkT >::value_type apply (typename BinOp::second_argument_type const &a, BinOp const &op) noexcept(noexcept(op.operator()(std::declval< value_type >(), std::declval< typename BinOp::second_argument_type >())))
 
template<class V1 >
atomic_ctr_gen< V, LkT >::value_type apply (V1 const &a, std::plus< V1 > const &) noexcept(true)
 
template<class V1 >
atomic_ctr_gen< V, LkT >::value_type apply (V1 const &a, std::minus< V1 > const &) noexcept(true)
 
template<class Op >
atomic_ctr_gen< V, LkT > assign (Op &&op) noexcept(true)
 
- Public Member Functions inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::sp_counter_itf_type< V >
virtual ~sp_counter_itf_type ()
 
virtual value_type sp_count () const noexcept(true)
 
virtual value_type sp_acquire () noexcept(true)
 
virtual bool sp_release () noexcept(true)
 
constexpr bool FORCE_INLINE operator== (const value_type v) const noexcept(true)
 
virtual void deleter ()
 Call the correct deleter_t object to delete the object. More...
 
virtual tstring sp_to_string () const noexcept(false)
 

Static Public Attributes

static constexpr generic_traits::memory_access_modes memory_access_mode =generic_traits::memory_access_modes::erew_memory_access
 
- Static Public Attributes inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::sp_counter_itf_type< V >
static constexpr ppd::generic_traits::memory_access_modes memory_access_mode =ppd::generic_traits::memory_access_modes::crew_memory_access
 

Protected Attributes

value_type count
 
atomic_t locker
 

Friends

template<class V1 , class LkT1 >
class atomic_ctr_gen
 

Additional Inherited Members

- Protected Member Functions inherited from jmmcg::LIBJMMCG_VER_NAMESPACE::sp_counter_itf_type< V >
constexpr sp_counter_itf_type () noexcept(true)
 

Detailed Description

template<class V, class LkT>
class jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >

A general-purpose, atomic counter class, similar to the atomic integer types in C++11 ch 29.

Note that this class is a valid value-type. Also note that this class reduces to a simple V-type, if it is single threaded, so costs nothing.

Definition at line 125 of file atomic_counter.hpp.

Member Typedef Documentation

◆ atomic_t

template<class V , class LkT >
typedef lock_traits::recursive_critical_section_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::atomic_t

Definition at line 129 of file atomic_counter.hpp.

◆ base_t

template<class V , class LkT >
typedef sp_counter_itf_type<V> jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::base_t

Definition at line 127 of file atomic_counter.hpp.

◆ lock_traits

template<class V , class LkT >
typedef LkT jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::lock_traits

Definition at line 128 of file atomic_counter.hpp.

◆ value_type

template<class V , class LkT >
typedef base_t::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::value_type

Definition at line 130 of file atomic_counter.hpp.

Constructor & Destructor Documentation

◆ atomic_ctr_gen() [1/5]

◆ atomic_ctr_gen() [2/5]

◆ atomic_ctr_gen() [3/5]

◆ atomic_ctr_gen() [4/5]

template<class V , class LkT >
template<class V1 >
constexpr jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::atomic_ctr_gen ( const atomic_ctr_gen< V1, LkT > &  a)
inlineconstexprnoexcept

◆ atomic_ctr_gen() [5/5]

◆ ~atomic_ctr_gen()

template<class V , class LkT >
jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::~atomic_ctr_gen
inlinenoexcept

Definition at line 54 of file atomic_counter_impl.hpp.

Member Function Documentation

◆ apply() [1/6]

template<class V , class LkT >
template<class BinOp >
atomic_ctr_gen<V, LkT>::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::apply ( typename BinOp::second_argument_type const &  a,
BinOp const &  op 
)
inlinenoexcept

◆ apply() [2/6]

template<class V , class LkT >
template<class BinOp >
value_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::apply ( typename BinOp::second_argument_type const &  a,
BinOp const &  op 
)
noexcept

◆ apply() [3/6]

template<class V , class LkT >
template<class V1 >
atomic_ctr_gen<V, LkT>::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::apply ( V1 const &  a,
std::minus< V1 > const &   
)
inlinenoexcept

Definition at line 257 of file atomic_counter_impl.hpp.

◆ apply() [4/6]

template<class V , class LkT >
template<class V1 >
value_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::apply ( V1 const &  a,
std::minus< V1 > const &   
)
noexcept

◆ apply() [5/6]

template<class V , class LkT >
template<class V1 >
atomic_ctr_gen<V, LkT>::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::apply ( V1 const &  a,
std::plus< V1 > const &   
)
inlinenoexcept

Definition at line 249 of file atomic_counter_impl.hpp.

◆ apply() [6/6]

template<class V , class LkT >
template<class V1 >
value_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::apply ( V1 const &  a,
std::plus< V1 > const &   
)
noexcept

◆ assign() [1/2]

template<class V , class LkT >
template<class Op >
atomic_ctr_gen<V, LkT> jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::assign ( Op &&  op)
inlinenoexcept

Definition at line 290 of file atomic_counter_impl.hpp.

◆ assign() [2/2]

template<class V , class LkT >
template<class Op >
atomic_ctr_gen jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::assign ( Op &&  op)
noexcept

◆ compare_exchange_strong() [1/2]

template<class V , class LkT >
template<class V1 , class V2 >
std::enable_if< std::is_pointer< V2 >::value, bool >::type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::compare_exchange_strong ( value_type  expected,
V1  desired 
)
inlinenoexcept

◆ compare_exchange_strong() [2/2]

template<class V , class LkT >
bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::compare_exchange_strong ( value_type  expected,
value_type  desired 
)
inlinenoexcept

◆ get()

template<class V , class LkT >
constexpr atomic_ctr_gen< V, LkT >::value_type const & jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::get
inlineconstexprnoexcept

◆ operator!()

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator!
inlineconstexprnoexcept

Definition at line 123 of file atomic_counter_impl.hpp.

◆ operator!=() [1/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator!= ( const atomic_ctr_gen< V, LkT > &  a) const
inlineconstexprnoexcept

Definition at line 118 of file atomic_counter_impl.hpp.

◆ operator!=() [2/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator!= ( const value_type  v) const
inlineconstexprnoexcept

Definition at line 113 of file atomic_counter_impl.hpp.

◆ operator++() [1/2]

template<class V , class LkT >
atomic_ctr_gen< V, LkT >::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator++
inlinenoexcept
Returns
Atomically increment and return that incremented value.

Definition at line 178 of file atomic_counter_impl.hpp.

References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::count, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::locker.

◆ operator++() [2/2]

template<class V , class LkT >
atomic_ctr_gen< V, LkT >::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator++ ( int  )
inlinenoexcept

◆ operator+=() [1/2]

◆ operator+=() [2/2]

◆ operator--() [1/2]

template<class V , class LkT >
atomic_ctr_gen< V, LkT >::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator--
inlinenoexcept
Returns
Atomically decrement and return that incremented value.

Definition at line 192 of file atomic_counter_impl.hpp.

References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::count, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::locker.

◆ operator--() [2/2]

template<class V , class LkT >
atomic_ctr_gen< V, LkT >::value_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator-- ( int  )
inlinenoexcept

◆ operator-=() [1/2]

◆ operator-=() [2/2]

◆ operator->()

template<class V , class LkT >
template<class V1 = value_type>
std::enable_if<std::is_pointer<V1>::value, V1>::type FORCE_INLINE jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator-> ( ) const
inlinenoexcept

◆ operator<() [1/3]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator< ( base_t const &  a) const
inlineconstexprnoexcept

Definition at line 137 of file atomic_counter_impl.hpp.

◆ operator<() [2/3]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator< ( const atomic_ctr_gen< V, LkT > &  a) const
inlineconstexprnoexcept

◆ operator<() [3/3]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator< ( const value_type  v) const
inlineconstexproverridevirtualnoexcept

◆ operator<=() [1/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator<= ( const atomic_ctr_gen< V, LkT > &  a) const
inlineconstexprnoexcept

◆ operator<=() [2/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator<= ( const value_type  v) const
inlineconstexprnoexcept

◆ operator=() [1/4]

◆ operator=() [2/4]

template<class V , class LkT >
template<class V1 , class V2 >
std::enable_if<std::is_pointer<V2>::value, void>::type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator= ( const atomic_ctr_gen< V1, LkT > &  a)
inlinenoexcept

◆ operator=() [3/4]

template<class V , class LkT >
template<class V1 , class V2 = V1>
std::enable_if<std::is_pointer<V2>::value, void>::type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator= ( const atomic_ctr_gen< V1, LkT > &  v)
noexcept

◆ operator=() [4/4]

◆ operator==() [1/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator== ( const atomic_ctr_gen< V, LkT > &  a) const
inlineconstexprnoexcept

◆ operator==() [2/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator== ( const value_type  v) const
inlineconstexprnoexcept

◆ operator>() [1/3]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator> ( base_t const &  a) const
inlineconstexprnoexcept

Definition at line 153 of file atomic_counter_impl.hpp.

◆ operator>() [2/3]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator> ( const atomic_ctr_gen< V, LkT > &  a) const
inlineconstexprnoexcept

◆ operator>() [3/3]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator> ( const value_type  v) const
inlineconstexproverridevirtualnoexcept

◆ operator>=() [1/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator>= ( const atomic_ctr_gen< V, LkT > &  a) const
inlineconstexprnoexcept

◆ operator>=() [2/2]

template<class V , class LkT >
constexpr bool jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::operator>= ( const value_type  v) const
inlineconstexproverridevirtualnoexcept

◆ sp_noop_ctr()

template<class V , class LkT >
constexpr bool FORCE_INLINE jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::sp_noop_ctr ( ) const
inlineconstexproverridevirtualnoexcept

This is a hack: we could use a dynamic_cast to check this, but in GCC dynamic_casts involve strcmps which may be slowish, so use a virtual thunk instead, which should be faster.

Reimplemented from jmmcg::LIBJMMCG_VER_NAMESPACE::sp_counter_itf_type< V >.

Definition at line 153 of file atomic_counter.hpp.

◆ swap() [1/2]

◆ swap() [2/2]

template<class V , class LkT >
template<class V1 , class V2 >
std::enable_if< std::is_pointer< V2 >::value, void >::type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::atomic_ctr_gen< V, LkT >::swap ( atomic_ctr_gen< V1, LkT > &  rhs)
inlinenoexcept

Friends And Related Function Documentation

◆ atomic_ctr_gen

template<class V , class LkT >
template<class V1 , class LkT1 >
friend class atomic_ctr_gen
friend

Definition at line 210 of file atomic_counter.hpp.

Member Data Documentation

◆ count

◆ locker

◆ memory_access_mode

To assist in allowing compile-time computation of the algorithmic order of the threading model.

Definition at line 134 of file atomic_counter.hpp.


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