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 constexpr

Definition at line 285 of file atomic.h.

:my_storage(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.

{
return to_value<value_type>(
internal::atomic_traits<sizeof(value_type),M>::compare_and_swap( &my_storage.my_value, to_bits(value), to_bits(comparand) )
);
}

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.

{
return compare_and_swap<full_fence>(value,comparand);
}

## 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.

{
return to_value<value_type>(
internal::atomic_traits<sizeof(value_type),M>::fetch_and_store( &my_storage.my_value, to_bits(value) )
);
}

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.

{
return fetch_and_store<full_fence>(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.

{
return to_value<value_type>(
internal::atomic_load_store_traits<M>::load( to_bits_ref(my_storage.my_value) )
);
}

## load() [2/2]

template<typename T>

value_type tbb::internal::atomic_impl< T >::load | ( |  | ) | const

inline

Definition at line 322 of file atomic.h.

{
return load<acquire>();
}

## 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.

{ // volatile qualifier here for backwards compatibility
return to_value<value_type>(
__TBB_load_with_acquire( to_bits_ref(my_storage.my_value) )
);
}

## 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.

{
internal::atomic_load_store_traits<M>::store( to_bits_ref(my_storage.my_value), to_bits(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.

{
store<release>( value );
}

## store_with_release()

template<typename T>

value_type tbb::internal::atomic_impl< T >::store_with_release | ( | value_type | rhs | ) |

inline protected

Definition at line 336 of file atomic.h.

{
//TODO: unify with store<release>
__TBB_store_with_release( to_bits_ref(my_storage.my_value), to_bits(rhs) );
return rhs;
}

## 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 | ) |

inline static private

Definition at line 246 of file atomic.h.

{
return converter<value_t>(value).bits;
}

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 | ) |

inline static private

Definition at line 269 of file atomic.h.

{
//TODO: this #ifdef is temporary workaround, as union conversion seems to fail
//on suncc for 64 bit types for 32 bit target
#if !__SUNPRO_CC
return *(typename converter<value_t>::bits_type*)ptr_converter<value_t*>(&value).bits;
#else
return *(typename converter<value_t>::bits_type*)(&value);
#endif
}

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 | ) |

inline static private

Definition at line 250 of file atomic.h.

{
converter<value_t> u;
u.bits = bits;
return u.value;
}

## Member Data Documentation

## my_storage

template<typename T>

aligned_storage<T,sizeof(T)> tbb::internal::atomic_impl< T >::my_storage

protected

Definition at line 232 of file atomic.h.

Referenced by tbb::internal::atomic_impl< I >::compare_and_swap(), tbb::internal::atomic_impl< I >::fetch_and_store(), 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().

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

- atomic.h

tbb::internal::__TBB_load_with_acquire
T __TBB_load_with_acquire(const volatile T &location)
Definition: tbb_machine.h:712
tbb::internal::atomic_impl::my_storage
aligned_storage< T, sizeof(T)> my_storage
Definition: atomic.h:232
tbb::store
void store(atomic< T > &a, T value)
Definition: atomic.h:549
tbb::internal::atomic_impl::to_bits
static converter< value_t >::bits_type to_bits(value_t value)
Definition: atomic.h:246
tbb::internal::atomic_impl::converter::bits_type
atomic_rep< sizeof(value_type)>::word bits_type
Definition: atomic.h:238
tbb::internal::atomic_impl::compare_and_swap
value_type compare_and_swap(value_type value, value_type comparand)
Definition: atomic.h:299
tbb::internal::atomic_impl::value_type
T value_type
Definition: atomic.h:281
tbb::internal::__TBB_store_with_release
void __TBB_store_with_release(volatile T &location, V value)
Definition: tbb_machine.h:716
tbb::load
struct __TBB_DEPRECATED_VERBOSE_MSG("tbb::atomic is deprecated, use std::atomic") atomic< T * > struct __TBB_DEPRECATED_VERBOSE_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
tbb::internal::atomic_impl::fetch_and_store
value_type fetch_and_store(value_type value)
Definition: atomic.h:288
tbb::internal::atomic_impl::to_bits_ref
static converter< value_t >::bits_type & to_bits_ref(value_t &value)
Definition: atomic.h:269
value
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
Definition: ittnotify_static.h:192

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.