cds  2.3.2
cds::atomicity::cache_friendly_item_counter Class Reference

Atomic cache-friendly item counter. More...

#include <cds/algo/atomic.h>

Public Types

typedef atomics::atomic_size_t atomic_type
 atomic type used
 
typedef size_t counter_type
 Integral item counter type (size_t)
 

Public Member Functions

 cache_friendly_item_counter ()
 Default ctor initializes the counter to zero.
 
counter_type value (atomics::memory_order order=atomics::memory_order_relaxed) const
 Returns current value of the counter.
 
 operator counter_type () const
 Same as value() with relaxed memory ordering.
 
atomic_typegetAtomic ()
 Returns underlying atomic interface.
 
const atomic_typegetAtomic () const
 Returns underlying atomic interface (const)
 
counter_type inc (atomics::memory_order order=atomics::memory_order_relaxed)
 Increments the counter. Semantics: postincrement.
 
counter_type inc (counter_type count, atomics::memory_order order=atomics::memory_order_relaxed)
 Increments the counter. Semantics: postincrement.
 
counter_type dec (atomics::memory_order order=atomics::memory_order_relaxed)
 Decrements the counter. Semantics: postdecrement.
 
counter_type dec (counter_type count, atomics::memory_order order=atomics::memory_order_relaxed)
 Decrements the counter. Semantics: postdecrement.
 
counter_type operator++ ()
 Preincrement.
 
counter_type operator++ (int)
 Postincrement.
 
counter_type operator-- ()
 Predecrement.
 
counter_type operator-- (int)
 Postdecrement.
 
counter_type operator+= (counter_type count)
 Increment by count.
 
counter_type operator-= (counter_type count)
 Decrement by count.
 
void reset (atomics::memory_order order=atomics::memory_order_relaxed)
 Resets count to 0.
 

Detailed Description

Atomic cache-friendly item counter.

Atomic item counter with cache-line padding to avoid false sharing. Adding cache-line padding before and after atomic counter eliminates the contention in read path of many containers and can notably improve search operations in sets/maps.


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

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:15 by Doxygen 1.8.13