26#ifndef TEMPTABLE_LOCK_FREE_TYPE_H
27#define TEMPTABLE_LOCK_FREE_TYPE_H
67#if defined(__clang__) && (SIZEOF_VOIDP == 4) && (ATOMIC_LLONG_LOCK_FREE == 1)
68#define WORKAROUND_PR31864_CLANG_BUG (1)
70#define WORKAROUND_PR31864_CLANG_BUG (0)
105template <
typename T,
typename V =
void>
108 !std::is_same<T, T>::value,
109 "No always-lock-free property could be found for given type. "
110 "Type provided is probably not a built-in (fundamental) type or a "
111 "pointer which makes it impossible for this particular check to be "
112 "excercised at compile-time.");
124 T, typename
std::enable_if<std::is_class<T>::value and
125 std::is_trivially_copyable<T>::value>
::type> {
126 static_assert(!std::is_same<T, T>::value,
127 "Querying always-lock-free property of trivially-copyable "
128 "classes or structs is not yet implemented!");
134 T, typename
std::enable_if<std::is_pointer<T>::value>
::type> {
135#if (ATOMIC_POINTER_LOCK_FREE == 2)
139 "Pointer type on this platform does not have an "
140 "always-lock-free property. Bailing out ...");
148 typename
std::enable_if<std::is_same<T, long long>::value or
149 std::is_same<T, unsigned long long>::value>
::type> {
150#if (ATOMIC_LLONG_LOCK_FREE == 2) || (WORKAROUND_PR31864_CLANG_BUG == 1)
154 "(unsigned) long long type on this platform does not have an "
155 "always-lock-free property. Bailing out ...");
162 T, typename
std::enable_if<std::is_same<T, long>::value or
163 std::is_same<T, unsigned long>::value>
::type> {
164#if (ATOMIC_LONG_LOCK_FREE == 2)
168 "(unsigned) long type on this platform does not have an "
169 "always-lock-free property. Bailing out ...");
176 T, typename
std::enable_if<std::is_same<T, int>::value or
177 std::is_same<T, unsigned int>::value>
::type> {
178#if (ATOMIC_INT_LOCK_FREE == 2)
182 "(unsigned) int type on this platform does not have an "
183 "always-lock-free property. Bailing out ...");
190 T, typename
std::enable_if<std::is_same<T, short>::value or
191 std::is_same<T, unsigned short>::value>
::type> {
192#if (ATOMIC_SHORT_LOCK_FREE == 2)
196 "(unsigned) short type on this platform does not have an "
197 "always-lock-free property. Bailing out ...");
204 T, typename
std::enable_if<std::is_same<T, char>::value or
205 std::is_same<T, unsigned char>::value>
::type> {
206#if (ATOMIC_CHAR_LOCK_FREE == 2)
210 "(unsigned) char type on this platform does not have an "
211 "always-lock-free property. Bailing out ...");
218 T, typename
std::enable_if<std::is_same<T, bool>::value>
::type> {
219#if (ATOMIC_BOOL_LOCK_FREE == 2)
223 "bool type on this platform does not have an "
224 "always-lock-free property. Bailing out ...");
235template <
typename T,
typename V =
void>
238 !std::is_same<T, T>::value,
239 "No always-lock-free property could be found for given type. "
240 "Type provided is probably not a built-in (fundamental) type or a "
241 "pointer which makes it impossible for this particular check to be "
242 "excercised at compile-time.");
248 T, typename
std::enable_if<std::is_pointer<T>::value>
::type> {
249#if (ATOMIC_POINTER_LOCK_FREE == 2)
253 "Pointer type on this platform does not have an "
254 "always-lock-free property. Bailing out ...");
261 T, typename
std::enable_if<std::is_integral<T>::value>
::type> {
262#if (ATOMIC_LLONG_LOCK_FREE == 2) || (WORKAROUND_PR31864_CLANG_BUG == 1)
263 using Type = std::conditional_t<std::is_unsigned<T>::value,
264 unsigned long long,
long long>;
265#elif (ATOMIC_LONG_LOCK_FREE == 2)
267 std::conditional_t<std::is_unsigned<T>::value,
unsigned long,
long>;
268#elif (ATOMIC_INT_LOCK_FREE == 2)
270 std::conditional_t<std::is_unsigned<T>::value,
unsigned int,
int>;
271#elif (ATOMIC_SHORT_LOCK_FREE == 2)
273 std::conditional_t<std::is_unsigned<T>::value,
unsigned short,
short>;
274#elif (ATOMIC_CHAR_LOCK_FREE == 2)
276 std::conditional_t<std::is_unsigned<T>::value,
unsigned char,
char>;
277#elif (ATOMIC_BOOL_LOCK_FREE == 2)
282 "No suitable always-lock-free type was found for this platform. "
301 template <
typename,
typename =
void>
class TypeSelector =
312template <
typename T,
template <
typename,
typename =
void>
class TypeSelector>
Type
Definition: resource_group_basic_types.h:32
Definition: varlen_sort.h:183
Definition: allocator.h:44
Alignment
Enum class describing alignment-requirements.
Definition: lock_free_type.h:74
constexpr size_t L1_DCACHE_SIZE
Store L1-dcache size information into the constexpr expression.
Definition: constants.h:81
required string type
Definition: replication_group_member_actions.proto:33
Largest lock-free type selector, a helper utility very much similar to Lock_free_type_selector with t...
Definition: lock_free_type.h:236
typename TypeSelector< T >::Type Type
Definition: lock_free_type.h:314
Lock-free type selector, a helper utility which evaluates during the compile-time whether the given t...
Definition: lock_free_type.h:106
Representation of an atomic type which is guaranteed to be always-lock-free.
Definition: lock_free_type.h:303
typename TypeSelector< T >::Type Type
Definition: lock_free_type.h:304
std::atomic< Type > m_value
Definition: lock_free_type.h:305