Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
Go to the documentation of this file.
19 #if !defined(__TBB_show_deprecation_message_atomic_H) && defined(__TBB_show_deprecated_header_message)
20 #define __TBB_show_deprecation_message_atomic_H
21 #pragma message("TBB Warning: tbb/atomic.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
24 #if defined(__TBB_show_deprecated_header_message)
25 #undef __TBB_show_deprecated_header_message
28 #ifndef __TBB_atomic_H
29 #define __TBB_atomic_H
31 #define __TBB_atomic_H_include_area
37 #define __TBB_LONG_LONG __int64
39 #define __TBB_LONG_LONG long long
44 #if _MSC_VER && !__INTEL_COMPILER
46 #pragma warning (push)
47 #pragma warning (disable: 4244 4267 4512)
67 #if __TBB_ALIGNAS_PRESENT
68 #define __TBB_DECL_ATOMIC_FIELD(t,f,a) alignas(a) t f;
69 #elif __TBB_ATTRIBUTE_ALIGNED_PRESENT
70 #define __TBB_DECL_ATOMIC_FIELD(t,f,a) t f __attribute__ ((aligned(a)));
71 #elif __TBB_DECLSPEC_ALIGN_PRESENT
72 #define __TBB_DECL_ATOMIC_FIELD(t,f,a) __declspec(align(a)) t f;
74 #error Do not know syntax for forcing alignment.
90 #if _MSC_VER && !_WIN64
92 typedef intptr_t
word;
97 #if __TBB_64BIT_ATOMICS
104 template<
typename value_type,
size_t size>
108 #if __TBB_ATOMIC_CTORS
109 #define ATOMIC_STORAGE_PARTIAL_SPECIALIZATION(S) \
110 template<typename value_type> \
111 struct aligned_storage<value_type,S> { \
112 __TBB_DECL_ATOMIC_FIELD(value_type,my_value,S) \
113 aligned_storage() = default ; \
114 constexpr aligned_storage(value_type value):my_value(value){} \
118 #define ATOMIC_STORAGE_PARTIAL_SPECIALIZATION(S) \
119 template<typename value_type> \
120 struct aligned_storage<value_type,S> { \
121 __TBB_DECL_ATOMIC_FIELD(value_type,my_value,S) \
126 template<
typename value_type>
129 #if __TBB_ATOMIC_CTORS
137 #if __TBB_64BIT_ATOMICS
141 template<
size_t Size, memory_semantics M>
144 #define __TBB_DECL_FENCED_ATOMIC_PRIMITIVES(S,M) \
145 template<> struct atomic_traits<S,M> { \
146 typedef atomic_rep<S>::word word; \
147 inline static word compare_and_swap( volatile void* location, word new_value, word comparand ) { \
148 return __TBB_machine_cmpswp##S##M(location,new_value,comparand); \
150 inline static word fetch_and_add( volatile void* location, word addend ) { \
151 return __TBB_machine_fetchadd##S##M(location,addend); \
153 inline static word fetch_and_store( volatile void* location, word value ) { \
154 return __TBB_machine_fetchstore##S##M(location,value); \
158 #define __TBB_DECL_ATOMIC_PRIMITIVES(S) \
159 template<memory_semantics M> \
160 struct atomic_traits<S,M> { \
161 typedef atomic_rep<S>::word word; \
162 inline static word compare_and_swap( volatile void* location, word new_value, word comparand ) { \
163 return __TBB_machine_cmpswp##S(location,new_value,comparand); \
165 inline static word fetch_and_add( volatile void* location, word addend ) { \
166 return __TBB_machine_fetchadd##S(location,addend); \
168 inline static word fetch_and_store( volatile void* location, word value ) { \
169 return __TBB_machine_fetchstore##S(location,value); \
173 template<memory_semantics M>
176 #define __TBB_DECL_ATOMIC_LOAD_STORE_PRIMITIVES(M) \
177 template<> struct atomic_load_store_traits<M> { \
178 template <typename T> \
179 inline static T load( const volatile T& location ) { \
180 return __TBB_load_##M( location ); \
182 template <typename T> \
183 inline static void store( volatile T& location, T value ) { \
184 __TBB_store_##M( location, value ); \
188 #if __TBB_USE_FENCED_ATOMICS
201 #if __TBB_64BIT_ATOMICS
211 #if __TBB_64BIT_ATOMICS
224 #define __TBB_MINUS_ONE(T) (T(T(0)-T(1)))
236 template<
typename value_type>
245 template<
typename value_t>
247 return converter<value_t>(
value).bits;
249 template<
typename value_t>
251 converter<value_t> u;
256 template<
typename value_t>
259 template<
typename value_t>
268 template<
typename value_t>
283 #if __TBB_ATOMIC_CTORS
287 template<memory_semantics M>
289 return to_value<value_type>(
295 return fetch_and_store<full_fence>(
value);
298 template<memory_semantics M>
300 return to_value<value_type>(
306 return compare_and_swap<full_fence>(
value,comparand);
310 return to_value<value_type>(
315 template<memory_semantics M>
317 return to_value<value_type>(
323 return load<acquire>();
326 template<memory_semantics M>
332 store<release>(
value );
347 template<
typename I,
typename D,
typename StepType>
351 #if __TBB_ATOMIC_CTORS
355 template<memory_semantics M>
361 return fetch_and_add<full_fence>(addend);
364 template<memory_semantics M>
366 return fetch_and_add<M>(1);
373 template<memory_semantics M>
418 atomic: internal::atomic_impl<T> {
419 #if __TBB_ATOMIC_CTORS
421 constexpr atomic(T arg):
internal::atomic_impl<T>(arg) {}
422 constexpr atomic<T>(
const atomic<T>& rhs):
internal::atomic_impl<T>(rhs) {}
424 T operator=( T rhs ) {
426 return this->store_with_release(rhs);
428 atomic<T>& operator=(
const atomic<T>& rhs ) {this->store_with_release(rhs);
return *
this;}
431 #if __TBB_ATOMIC_CTORS
432 #define __TBB_DECL_ATOMIC(T) \
433 template<> struct __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::atomic is deprecated, use std::atomic") \
434 atomic<T>: internal::atomic_impl_with_arithmetic<T,T,char> { \
435 atomic() = default; \
436 constexpr atomic(T arg): internal::atomic_impl_with_arithmetic<T,T,char>(arg) {} \
437 constexpr atomic<T>(const atomic<T>& rhs): \
438 internal::atomic_impl_with_arithmetic<T,T,char>(rhs) {} \
440 T operator=( T rhs ) {return store_with_release(rhs);} \
441 atomic<T>& operator=( const atomic<T>& rhs ) {store_with_release(rhs); return *this;} \
444 #define __TBB_DECL_ATOMIC(T) \
445 template<> struct __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::atomic is deprecated, use std::atomic") \
446 atomic<T>: internal::atomic_impl_with_arithmetic<T,T,char> { \
447 T operator=( T rhs ) {return store_with_release(rhs);} \
448 atomic<T>& operator=( const atomic<T>& rhs ) {store_with_release(rhs); return *this;} \
452 #if __TBB_64BIT_ATOMICS
462 #if _MSC_VER && !_WIN64
463 #if __TBB_ATOMIC_CTORS
469 #define __TBB_DECL_ATOMIC_ALT(T,U) \
470 template<> struct __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::atomic is deprecated, use std::atomic") \
471 atomic<T>: internal::atomic_impl_with_arithmetic<T,T,char> { \
472 atomic() = default ; \
473 constexpr atomic(T arg): internal::atomic_impl_with_arithmetic<T,T,char>(arg) {} \
474 constexpr atomic<T>(const atomic<T>& rhs): \
475 internal::atomic_impl_with_arithmetic<T,T,char>(rhs) {} \
477 T operator=( U rhs ) {return store_with_release(T(rhs));} \
478 atomic<T>& operator=( const atomic<T>& rhs ) {store_with_release(rhs); return *this;} \
481 #define __TBB_DECL_ATOMIC_ALT(T,U) \
482 template<> struct __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::atomic is deprecated, use std::atomic") \
483 atomic<T>: internal::atomic_impl_with_arithmetic<T,T,char> { \
484 T operator=( U rhs ) {return store_with_release(T(rhs));} \
485 atomic<T>& operator=( const atomic<T>& rhs ) {store_with_release(rhs); return *this;} \
488 __TBB_DECL_ATOMIC_ALT(
unsigned,
size_t)
489 __TBB_DECL_ATOMIC_ALT(
int,ptrdiff_t)
501 #if !_MSC_VER || defined(_NATIVE_WCHAR_T_DEFINED)
507 atomic<T*>: internal::atomic_impl_with_arithmetic<T*,ptrdiff_t,T> {
508 #if __TBB_ATOMIC_CTORS
510 constexpr atomic(T* arg): internal::atomic_impl_with_arithmetic<T*,ptrdiff_t,T>(arg) {}
511 constexpr atomic(
const atomic<T*>& rhs): internal::atomic_impl_with_arithmetic<T*,ptrdiff_t,T>(rhs) {}
513 T* operator=( T* rhs ) {
515 return this->store_with_release(rhs);
517 atomic<T*>& operator=(
const atomic<T*>& rhs ) {
518 this->store_with_release(rhs);
return *
this;
520 T* operator->()
const {
527 atomic<void*>: internal::atomic_impl<void*> {
528 #if __TBB_ATOMIC_CTORS
530 constexpr atomic(
void* arg):
internal::atomic_impl<
void*>(arg) {}
531 constexpr atomic(
const atomic<void*>& rhs):
internal::atomic_impl<
void*>(rhs) {}
533 void* operator=(
void* rhs ) {
535 return this->store_with_release(rhs);
537 atomic<void*>& operator=(
const atomic<void*>& rhs ) {
538 this->store_with_release(rhs);
return *
this;
545 template <memory_semantics M,
typename T>
546 T
load (
const atomic<T>& a ) {
return a.template load<M>(); }
548 template <memory_semantics M,
typename T>
551 namespace interface6{
563 template<memory_semantics M,
typename T >
564 void swap(atomic<T> & lhs, atomic<T> & rhs){
565 T tmp = load<M>(lhs);
566 store<M>(lhs,load<M>(rhs));
573 return (atomic<T>&)t;
579 #if _MSC_VER && !__INTEL_COMPILER
580 #pragma warning (pop)
581 #endif // warnings are restored
584 #undef __TBB_atomic_H_include_area
T __TBB_load_with_acquire(const volatile T &location)
void store(value_type value)
value_type fetch_and_store(value_type value)
void store(atomic< T > &a, T value)
ptr_converter(value_t *a_value)
Base class that provides basic functionality for atomic<T> without fetch_and_add.
converter(value_type a_value)
static value_t to_value(typename converter< value_t >::bits_type bits)
value_type fetch_and_increment()
__TBB_DECL_ATOMIC_LOAD_STORE_PRIMITIVES(full_fence)
void swap(atomic< T > &lhs, atomic< T > &rhs)
static converter< value_t >::bits_type & to_bits_ref(value_t &value)
value_type operator+=(D value)
#define __TBB_MINUS_ONE(T)
Additive inverse of 1 for type T.
Base class that provides basic functionality for atomic<T> with fetch_and_add.
value_type fetch_and_decrement()
static converter< value_t >::bits_type to_bits(value_t value)
value_type store_with_release(value_type rhs)
@ full_fence
Sequential consistency.
value_type compare_and_swap(value_type value, value_type comparand)
value_type fetch_and_add(D addend)
#define ATOMIC_STORAGE_PARTIAL_SPECIALIZATION(S)
atomic< T > make_atomic(T t)
Make an atomic for use in an initialization (list), as an alternative to zero-initialization or norma...
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->.
value_type operator++(int)
void __TBB_store_with_release(volatile T &location, V value)
#define __TBB_DECL_ATOMIC(T)
Primary template for atomic.
void store(value_type value)
class __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::aligned_space is deprecated, use std::aligned_storage") aligned_space
Block of space aligned sufficiently to construct an array T with N elements.
atomic_rep< sizeof(value_type)>::word bits_type
value_type compare_and_swap(value_type value, value_type comparand)
aligned_storage< T, sizeof(T)> my_storage
value_type fetch_and_increment()
value_type fetch_and_add(D addend)
value_type operator--(int)
value_type fetch_and_store(value_type value)
atomic< T > & as_atomic(T &t)
memory_semantics
Specifies memory semantics.
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 operator-=(D value)
value_type fetch_and_decrement()
#define __TBB_DECL_FENCED_ATOMIC_PRIMITIVES(S, M)
Union type used to convert type T to underlying integral type.
#define __TBB_DECL_ATOMIC_PRIMITIVES(S)
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.