5#include "system/threading/thread.h"
7namespace System {
namespace Threading {
16 static constexpr bool IsSupportedInt = std::is_same<T, int32_t>::value || std::is_same<T, uint32_t>::value ||
17 std::is_same<T, int64_t>::value || std::is_same<T, uint64_t>::value;
23 static ASPOSECPP_SHARED_API int32_t
Increment(int32_t& location);
27 static ASPOSECPP_SHARED_API int64_t
Increment(int64_t& location);
31 static ASPOSECPP_SHARED_API int32_t
Decrement(int32_t& location);
35 static ASPOSECPP_SHARED_API int64_t
Decrement(int64_t& location);
41 static ASPOSECPP_SHARED_API int32_t
Add(int32_t& location1, int32_t value);
46 static ASPOSECPP_SHARED_API int64_t
Add(int64_t& location1, int64_t value);
51 static ASPOSECPP_SHARED_API int64_t
Read(int64_t& location1);
57 static ASPOSECPP_SHARED_API int32_t
ExchangeAdd(int32_t& location1, int32_t value);
62 static ASPOSECPP_SHARED_API int64_t
ExchangeAdd(int64_t& location1, int64_t value);
70 static typename std::enable_if<IsSupportedInt<T>, T>::type
Exchange(T& location1, T value)
72 return std::atomic_exchange((std::atomic<T>*)&location1, value);
81 static typename std::enable_if<!IsSupportedInt<T>, T>::type
Exchange(T& location1, T value)
83 throw NotImplementedException(ASPOSE_CURRENT_FUNCTION);
94 static typename std::enable_if<IsSupportedInt<T>, T>::type
CompareExchange(T& location1, T value, T comparand)
96 auto orig = location1;
97 std::atomic_compare_exchange_strong((std::atomic<T>*)&location1, &comparand, value);
107 template <
typename T>
108 static typename std::enable_if<!IsSupportedInt<T>, T>::type
CompareExchange(T& location1, T value, T comparand)
110 throw NotImplementedException(ASPOSE_CURRENT_FUNCTION);
120 static ASPOSECPP_SHARED_API int32_t
CompareExchange(int32_t& location1, int32_t value, int32_t comparand,
Provides API for thread-safe operations. This is a static type with no instance services....
Definition: interlocked.h:13
static int32_t Increment(int32_t &location)
Increments value atomically.
static int32_t Add(int32_t &location1, int32_t value)
Increases value atomically.
static std::enable_if<!IsSupportedInt< T >, T >::type Exchange(T &location1, T value)
Exchanges value on variable: stores new value and returns the value variable had immediately before s...
Definition: interlocked.h:81
static std::enable_if< IsSupportedInt< T >, T >::type Exchange(T &location1, T value)
Exchanges value on variable: stores new value and returns the value variable had immediately before s...
Definition: interlocked.h:70
static int64_t Decrement(int64_t &location)
Decrements value atomically.
static int64_t Read(int64_t &location1)
Returns a 64-bit value, loaded as an atomic operation.
static int64_t Add(int64_t &location1, int64_t value)
Increases value atomically.
static std::enable_if<!IsSupportedInt< T >, T >::type CompareExchange(T &location1, T value, T comparand)
Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new...
Definition: interlocked.h:108
static std::enable_if< IsSupportedInt< T >, T >::type CompareExchange(T &location1, T value, T comparand)
Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new...
Definition: interlocked.h:94
static int32_t ExchangeAdd(int32_t &location1, int32_t value)
Increases value atomically via exchange-add procedure.
static int64_t ExchangeAdd(int64_t &location1, int64_t value)
Increases value atomically via exchange-add procedure.
static int32_t CompareExchange(int32_t &location1, int32_t value, int32_t comparand, bool &succeeded)
Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new...
static int64_t Increment(int64_t &location)
Increments value atomically.
static int32_t Decrement(int32_t &location)
Decrements value atomically.
Definition: db_command.h:9