27#ifndef TEMPTABLE_LOCK_FREE_TYPE_H
28#define TEMPTABLE_LOCK_FREE_TYPE_H
68#if defined(__clang__) && (SIZEOF_VOIDP == 4) && (ATOMIC_LLONG_LOCK_FREE == 1)
69#define WORKAROUND_PR31864_CLANG_BUG (1)
71#define WORKAROUND_PR31864_CLANG_BUG (0)
106template <
typename T,
typename V =
void>
109 !std::is_same<T, T>::value,
110 "No always-lock-free property could be found for given type. "
111 "Type provided is probably not a built-in (fundamental) type or a "
112 "pointer which makes it impossible for this particular check to be "
113 "excercised at compile-time.");
125 T, typename
std::enable_if<std::is_class<T>::value and
126 std::is_trivially_copyable<T>::value>
::type> {
127 static_assert(!std::is_same<T, T>::value,
128 "Querying always-lock-free property of trivially-copyable "
129 "classes or structs is not yet implemented!");
135 T, typename
std::enable_if<std::is_pointer<T>::value>
::type> {
136#if (ATOMIC_POINTER_LOCK_FREE == 2)
140 "Pointer type on this platform does not have an "
141 "always-lock-free property. Bailing out ...");
149 typename
std::enable_if<std::is_same<T, long long>::value or
150 std::is_same<T, unsigned long long>::value>
::type> {
151#if (ATOMIC_LLONG_LOCK_FREE == 2) || (WORKAROUND_PR31864_CLANG_BUG == 1)
155 "(unsigned) long long type on this platform does not have an "
156 "always-lock-free property. Bailing out ...");
163 T, typename
std::enable_if<std::is_same<T, long>::value or
164 std::is_same<T, unsigned long>::value>
::type> {
165#if (ATOMIC_LONG_LOCK_FREE == 2)
169 "(unsigned) long type on this platform does not have an "
170 "always-lock-free property. Bailing out ...");
177 T, typename
std::enable_if<std::is_same<T, int>::value or
178 std::is_same<T, unsigned int>::value>
::type> {
179#if (ATOMIC_INT_LOCK_FREE == 2)
183 "(unsigned) int type on this platform does not have an "
184 "always-lock-free property. Bailing out ...");
191 T, typename
std::enable_if<std::is_same<T, short>::value or
192 std::is_same<T, unsigned short>::value>
::type> {
193#if (ATOMIC_SHORT_LOCK_FREE == 2)
197 "(unsigned) short type on this platform does not have an "
198 "always-lock-free property. Bailing out ...");
205 T, typename
std::enable_if<std::is_same<T, char>::value or
206 std::is_same<T, unsigned char>::value>
::type> {
207#if (ATOMIC_CHAR_LOCK_FREE == 2)
211 "(unsigned) char type on this platform does not have an "
212 "always-lock-free property. Bailing out ...");
219 T, typename
std::enable_if<std::is_same<T, bool>::value>
::type> {
220#if (ATOMIC_BOOL_LOCK_FREE == 2)
224 "bool type on this platform does not have an "
225 "always-lock-free property. Bailing out ...");
236template <
typename T,
typename V =
void>
239 !std::is_same<T, T>::value,
240 "No always-lock-free property could be found for given type. "
241 "Type provided is probably not a built-in (fundamental) type or a "
242 "pointer which makes it impossible for this particular check to be "
243 "excercised at compile-time.");
249 T, typename
std::enable_if<std::is_pointer<T>::value>
::type> {
250#if (ATOMIC_POINTER_LOCK_FREE == 2)
254 "Pointer type on this platform does not have an "
255 "always-lock-free property. Bailing out ...");
262 T, typename
std::enable_if<std::is_integral<T>::value>
::type> {
263#if (ATOMIC_LLONG_LOCK_FREE == 2) || (WORKAROUND_PR31864_CLANG_BUG == 1)
264 using Type = std::conditional_t<std::is_unsigned<T>::value,
265 unsigned long long,
long long>;
266#elif (ATOMIC_LONG_LOCK_FREE == 2)
268 std::conditional_t<std::is_unsigned<T>::value,
unsigned long,
long>;
269#elif (ATOMIC_INT_LOCK_FREE == 2)
271 std::conditional_t<std::is_unsigned<T>::value,
unsigned int,
int>;
272#elif (ATOMIC_SHORT_LOCK_FREE == 2)
274 std::conditional_t<std::is_unsigned<T>::value,
unsigned short,
short>;
275#elif (ATOMIC_CHAR_LOCK_FREE == 2)
277 std::conditional_t<std::is_unsigned<T>::value,
unsigned char,
char>;
278#elif (ATOMIC_BOOL_LOCK_FREE == 2)
283 "No suitable always-lock-free type was found for this platform. "
302 template <
typename,
typename =
void>
class TypeSelector =
313template <
typename T,
template <
typename,
typename =
void>
class TypeSelector>
Type
Definition: resource_group_basic_types.h:33
Definition: gcs_xcom_synode.h:64
Definition: allocator.h:45
Alignment
Enum class describing alignment-requirements.
Definition: lock_free_type.h:75
constexpr size_t L1_DCACHE_SIZE
Store L1-dcache size information into the constexpr expression.
Definition: constants.h:82
required string type
Definition: replication_group_member_actions.proto:34
Largest lock-free type selector, a helper utility very much similar to Lock_free_type_selector with t...
Definition: lock_free_type.h:237
typename TypeSelector< T >::Type Type
Definition: lock_free_type.h:315
Lock-free type selector, a helper utility which evaluates during the compile-time whether the given t...
Definition: lock_free_type.h:107
Representation of an atomic type which is guaranteed to be always-lock-free.
Definition: lock_free_type.h:304
typename TypeSelector< T >::Type Type
Definition: lock_free_type.h:305
std::atomic< Type > m_value
Definition: lock_free_type.h:306