Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::internal::atomic_impl< T > Struct Template Reference

Base class that provides basic functionality for atomic<T> without fetch_and_add. More...

#include <atomic.h>

Inheritance diagram for tbb::internal::atomic_impl< T >:
Collaboration diagram for tbb::internal::atomic_impl< T >:

Classes

union  converter
 Union type used to convert type T to underlying integral type. More...
 
union  ptr_converter
 
union  ptr_converter< value_t * >
 

Public Types

typedef T value_type
 

Public Member Functions

 atomic_impl ()=default
 
constexpr atomic_impl (value_type value)
 
template<memory_semantics M>
value_type fetch_and_store (value_type value)
 
value_type fetch_and_store (value_type value)
 
template<memory_semantics M>
value_type compare_and_swap (value_type value, value_type comparand)
 
value_type compare_and_swap (value_type value, value_type comparand)
 
 operator value_type () const volatile
 
template<memory_semantics M>
value_type load () const
 
value_type load () const
 
template<memory_semantics M>
void store (value_type value)
 
void store (value_type value)
 

Protected Member Functions

value_type store_with_release (value_type rhs)
 

Protected Attributes

aligned_storage< T, sizeof(T)> my_storage
 

Static Private Member Functions

template<typename value_t >
static converter< value_t >::bits_type to_bits (value_t value)
 
template<typename value_t >
static value_t to_value (typename converter< value_t >::bits_type bits)
 
template<typename value_t >
static converter< value_t >::bits_type & to_bits_ref (value_t &value)
 

Detailed Description

template<typename T>
struct tbb::internal::atomic_impl< T >

Base class that provides basic functionality for atomic<T> without fetch_and_add.

Works for any type T that has the same size as an integral type, has a trivial constructor/destructor, and can be copied/compared by memcpy/memcmp.

Definition at line 230 of file atomic.h.

Member Typedef Documentation

◆ value_type

template<typename T>
typedef T tbb::internal::atomic_impl< T >::value_type

Definition at line 281 of file atomic.h.

Constructor & Destructor Documentation

◆ atomic_impl() [1/2]

template<typename T>
tbb::internal::atomic_impl< T >::atomic_impl ( )
default

◆ atomic_impl() [2/2]

template<typename T>
constexpr tbb::internal::atomic_impl< T >::atomic_impl ( value_type  value)
inline

Definition at line 285 of file atomic.h.

285 :my_storage(value){}
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

Member Function Documentation

◆ compare_and_swap() [1/2]

template<typename T>
template<memory_semantics M>
value_type tbb::internal::atomic_impl< T >::compare_and_swap ( value_type  value,
value_type  comparand 
)
inline

Definition at line 299 of file atomic.h.

299  {
300  return to_value<value_type>(
301  internal::atomic_traits<sizeof(value_type),M>::compare_and_swap( &my_storage.my_value, to_bits(value), to_bits(comparand) )
302  );
303  }
static converter< value_t >::bits_type to_bits(value_t value)
Definition: atomic.h:246
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
value_type compare_and_swap(value_type value, value_type comparand)
Definition: atomic.h:299
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

Referenced by tbb::internal::atomic_impl< I >::compare_and_swap().

Here is the caller graph for this function:

◆ compare_and_swap() [2/2]

template<typename T>
value_type tbb::internal::atomic_impl< T >::compare_and_swap ( value_type  value,
value_type  comparand 
)
inline

Definition at line 305 of file atomic.h.

305  {
306  return compare_and_swap<full_fence>(value,comparand);
307  }
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

◆ fetch_and_store() [1/2]

template<typename T>
template<memory_semantics M>
value_type tbb::internal::atomic_impl< T >::fetch_and_store ( value_type  value)
inline

Definition at line 288 of file atomic.h.

288  {
289  return to_value<value_type>(
290  internal::atomic_traits<sizeof(value_type),M>::fetch_and_store( &my_storage.my_value, to_bits(value) )
291  );
292  }
static converter< value_t >::bits_type to_bits(value_t value)
Definition: atomic.h:246
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
value_type fetch_and_store(value_type value)
Definition: atomic.h:288

Referenced by tbb::internal::atomic_impl< I >::fetch_and_store().

Here is the caller graph for this function:

◆ fetch_and_store() [2/2]

template<typename T>
value_type tbb::internal::atomic_impl< T >::fetch_and_store ( value_type  value)
inline

Definition at line 294 of file atomic.h.

294  {
295  return fetch_and_store<full_fence>(value);
296  }
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

◆ load() [1/2]

template<typename T>
template<memory_semantics M>
value_type tbb::internal::atomic_impl< T >::load ( ) const
inline

Definition at line 316 of file atomic.h.

316  {
317  return to_value<value_type>(
319  );
320  }
struct __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::atomic is deprecated, use std::atomic") atomic< T * > struct __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::atomic is deprecated, use std::atomic") atomic< void * > T load(const atomic< T > &a)
Specialization for atomic<T*> with arithmetic and operator->.
Definition: atomic.h:546
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
static converter< value_t >::bits_type & to_bits_ref(value_t &value)
Definition: atomic.h:269

◆ load() [2/2]

template<typename T>
value_type tbb::internal::atomic_impl< T >::load ( ) const
inline

Definition at line 322 of file atomic.h.

322  {
323  return load<acquire>();
324  }

◆ operator value_type()

template<typename T>
tbb::internal::atomic_impl< T >::operator value_type ( ) const volatile
inline

Definition at line 309 of file atomic.h.

309  { // volatile qualifier here for backwards compatibility
310  return to_value<value_type>(
312  );
313  }
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
static converter< value_t >::bits_type & to_bits_ref(value_t &value)
Definition: atomic.h:269
T __TBB_load_with_acquire(const volatile T &location)
Definition: tbb_machine.h:709

◆ store() [1/2]

template<typename T>
template<memory_semantics M>
void tbb::internal::atomic_impl< T >::store ( value_type  value)
inline

Definition at line 327 of file atomic.h.

327  {
329  }
static converter< value_t >::bits_type to_bits(value_t value)
Definition: atomic.h:246
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
static converter< value_t >::bits_type & to_bits_ref(value_t &value)
Definition: atomic.h:269
void store(atomic< T > &a, T value)
Definition: atomic.h:549
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

◆ store() [2/2]

template<typename T>
void tbb::internal::atomic_impl< T >::store ( value_type  value)
inline

Definition at line 331 of file atomic.h.

331  {
332  store<release>( value );
333  }
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

◆ store_with_release()

template<typename T>
value_type tbb::internal::atomic_impl< T >::store_with_release ( value_type  rhs)
inlineprotected

Definition at line 336 of file atomic.h.

336  {
337  //TODO: unify with store<release>
339  return rhs;
340  }
static converter< value_t >::bits_type to_bits(value_t value)
Definition: atomic.h:246
void __TBB_store_with_release(volatile T &location, V value)
Definition: tbb_machine.h:713
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
static converter< value_t >::bits_type & to_bits_ref(value_t &value)
Definition: atomic.h:269

◆ to_bits()

template<typename T>
template<typename value_t >
static converter<value_t>::bits_type tbb::internal::atomic_impl< T >::to_bits ( value_t  value)
inlinestaticprivate

Definition at line 246 of file atomic.h.

246  {
247  return converter<value_t>(value).bits;
248  }
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

Referenced by tbb::internal::atomic_impl< I >::compare_and_swap(), tbb::internal::atomic_impl< I >::fetch_and_store(), tbb::internal::atomic_impl< I >::store(), and tbb::internal::atomic_impl< I >::store_with_release().

Here is the caller graph for this function:

◆ to_bits_ref()

template<typename T>
template<typename value_t >
static converter<value_t>::bits_type& tbb::internal::atomic_impl< T >::to_bits_ref ( value_t &  value)
inlinestaticprivate

Definition at line 269 of file atomic.h.

269  {
270  //TODO: this #ifdef is temporary workaround, as union conversion seems to fail
271  //on suncc for 64 bit types for 32 bit target
272  #if !__SUNPRO_CC
273  return *(typename converter<value_t>::bits_type*)ptr_converter<value_t*>(&value).bits;
274  #else
275  return *(typename converter<value_t>::bits_type*)(&value);
276  #endif
277  }
atomic_rep< sizeof(value_type)>::word bits_type
Definition: atomic.h:238
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value

Referenced by tbb::internal::atomic_impl< I >::load(), tbb::internal::atomic_impl< I >::operator value_type(), tbb::internal::atomic_impl< I >::store(), and tbb::internal::atomic_impl< I >::store_with_release().

Here is the caller graph for this function:

◆ to_value()

template<typename T>
template<typename value_t >
static value_t tbb::internal::atomic_impl< T >::to_value ( typename converter< value_t >::bits_type  bits)
inlinestaticprivate

Definition at line 250 of file atomic.h.

250  {
251  converter<value_t> u;
252  u.bits = bits;
253  return u.value;
254  }

Member Data Documentation

◆ my_storage


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

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.