System::Threading::Interlocked Class Reference

Static Public Member Functions

static int32_t Increment (int32_t &location)
 
static int64_t Increment (int64_t &location)
 
static int32_t Decrement (int32_t &location)
 
static int64_t Decrement (int64_t &location)
 
static int32_t Add (int32_t &location1, int32_t value)
 
static int64_t Add (int64_t &location1, int64_t value)
 
static ASPOSECPP_SHARED_API int32_t ExchangeAdd (int32_t &location1, int32_t value)
 
static ASPOSECPP_SHARED_API int64_t ExchangeAdd (int64_t &location1, int64_t value)
 
static ASPOSECPP_SHARED_API int32_t Exchange (int32_t &location1, int32_t value)
 
static ASPOSECPP_SHARED_API int64_t Exchange (int64_t &location1, int64_t value)
 
static ASPOSECPP_SHARED_API float Exchange (float &location1, float value)
 
static ASPOSECPP_SHARED_API double Exchange (double &location1, double value)
 
template<typename T >
static T Exchange (T &location, T value)
 
static ASPOSECPP_SHARED_API int32_t CompareExchange (int32_t &location1, int32_t value, int32_t comparand)
 
static ASPOSECPP_SHARED_API int64_t CompareExchange (int64_t &location1, int64_t value, int64_t comparand)
 
static ASPOSECPP_SHARED_API float CompareExchange (float &location1, float value, float comparand)
 
static ASPOSECPP_SHARED_API double CompareExchange (double &location1, double value, double comparand)
 
template<typename T1 , typename T2 , typename T3 >
static T2 CompareExchange (T1 &location1, T2 value, T3 comparand)
 
static ASPOSECPP_SHARED_API int32_t CompareExchange (int32_t &location1, int32_t value, int32_t comparand, bool &succeeded)
 

Detailed Description

Provides API for thread-safe operations. This is a static type with no instance services. You should never create instances of it by any means.

Member Function Documentation

◆ Add() [1/2]

static int32_t System::Threading::Interlocked::Add ( int32_t &  location1,
int32_t  value 
)
inlinestatic

Increases value atomically.

Parameters
location1Variable reference to increase.
valueValue to add to location1.
Returns
Value of variable right after it was increased.

◆ Add() [2/2]

static int64_t System::Threading::Interlocked::Add ( int64_t &  location1,
int64_t  value 
)
inlinestatic

Increases value atomically.

Parameters
location1Variable reference to increase.
valueValue to add to location1.
Returns
Value of variable right after it was increased.

◆ CompareExchange() [1/6]

static ASPOSECPP_SHARED_API int32_t System::Threading::Interlocked::CompareExchange ( int32_t &  location1,
int32_t  value,
int32_t  comparand 
)
static

Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new value only if stored value matches expected.

Parameters
location1Variable reference to change.
valueValue to store.
comparandValue to compare variable's value to before exchanging.
Returns
Value of variable on operation start regardless whether it was changed or not.

◆ CompareExchange() [2/6]

static ASPOSECPP_SHARED_API int64_t System::Threading::Interlocked::CompareExchange ( int64_t &  location1,
int64_t  value,
int64_t  comparand 
)
static

Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new value only if stored value matches expected.

Parameters
location1Variable reference to change.
valueValue to store.
comparandValue to compare variable's value to before exchanging.
Returns
Value of variable on operation start regardless whether it was changed or not.

◆ CompareExchange() [3/6]

static ASPOSECPP_SHARED_API float System::Threading::Interlocked::CompareExchange ( float &  location1,
float  value,
float  comparand 
)
static

Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new value only if stored value matches expected.

Parameters
location1Variable reference to change.
valueValue to store.
comparandValue to compare variable's value to before exchanging.
Returns
Value of variable on operation start regardless whether it was changed or not.

◆ CompareExchange() [4/6]

static ASPOSECPP_SHARED_API double System::Threading::Interlocked::CompareExchange ( double &  location1,
double  value,
double  comparand 
)
static

Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new value only if stored value matches expected.

Parameters
location1Variable reference to change.
valueValue to store.
comparandValue to compare variable's value to before exchanging.
Returns
Value of variable on operation start regardless whether it was changed or not.

◆ CompareExchange() [5/6]

template<typename T1 , typename T2 , typename T3 >
static T2 System::Threading::Interlocked::CompareExchange ( T1 &  location1,
T2  value,
T3  comparand 
)
inlinestatic

Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new value only if stored value matches expected. Not implemented.

Template Parameters
T1Variable type.
T2Replacement value type.
T3Comparand type.
Parameters
location1Variable reference to change.
valueValue to store.
comparandValue to compare variable's value to before exchanging.
Returns
Value of variable on operation start regardless whether it was changed or not.

◆ CompareExchange() [6/6]

static ASPOSECPP_SHARED_API int32_t System::Threading::Interlocked::CompareExchange ( int32_t &  location1,
int32_t  value,
int32_t  comparand,
bool &  succeeded 
)
static

Compare-exchanges value on variable: checks if variable is equal to specific value and stores the new value only if stored value matches expected.

Parameters
location1Variable reference to change.
valueValue to store.
comparandValue to compare variable's value to before exchanging.
succeededReference to variable which is set to true if exchange took place and to false otherwise.
Returns
Value of variable on operation start regardless whether it was changed or not.

◆ Decrement() [1/2]

static int32_t System::Threading::Interlocked::Decrement ( int32_t &  location)
inlinestatic

Decrements value atomically.

Parameters
locationVariable reference to decrement.
Returns
Value of variable right after it was decremented.

◆ Decrement() [2/2]

static int64_t System::Threading::Interlocked::Decrement ( int64_t &  location)
inlinestatic

Decrements value atomically.

Parameters
locationVariable reference to decrement.
Returns
Value of variable right after it was decremented.

◆ Exchange() [1/5]

static ASPOSECPP_SHARED_API int32_t System::Threading::Interlocked::Exchange ( int32_t &  location1,
int32_t  value 
)
static

Exchanges value on variable: stores new value and returns the value variable had immediately before storing.

Parameters
location1Variable reference to change.
valueValue to store.
Returns
Value of variable right before it was changed.

◆ Exchange() [2/5]

static ASPOSECPP_SHARED_API int64_t System::Threading::Interlocked::Exchange ( int64_t &  location1,
int64_t  value 
)
static

Exchanges value on variable: stores new value and returns the value variable had immediately before storing.

Parameters
location1Variable reference to change.
valueValue to store.
Returns
Value of variable right before it was changed.

◆ Exchange() [3/5]

static ASPOSECPP_SHARED_API float System::Threading::Interlocked::Exchange ( float &  location1,
float  value 
)
static

Exchanges value on variable: stores new value and returns the value variable had immediately before storing.

Parameters
location1Variable reference to change.
valueValue to store.
Returns
Value of variable right before it was changed.

◆ Exchange() [4/5]

static ASPOSECPP_SHARED_API double System::Threading::Interlocked::Exchange ( double &  location1,
double  value 
)
static

Exchanges value on variable: stores new value and returns the value variable had immediately before storing.

Parameters
location1Variable reference to change.
valueValue to store.
Returns
Value of variable right before it was changed.

◆ Exchange() [5/5]

template<typename T >
static T System::Threading::Interlocked::Exchange ( T &  location,
value 
)
inlinestatic

Exchanges value on variable: stores new value and returns the value variable had immediately before storing. Not implemented.

Template Parameters
TVariable type.
Parameters
locationVariable reference to change.
valueValue to store.
Returns
Value of variable right before it was changed.

◆ ExchangeAdd() [1/2]

static ASPOSECPP_SHARED_API int32_t System::Threading::Interlocked::ExchangeAdd ( int32_t &  location1,
int32_t  value 
)
static

Increases value atomically via exchange-add procedure.

Parameters
location1Variable reference to increase.
valueValue to add to location1.
Returns
Value of variable right after it was increased.

◆ ExchangeAdd() [2/2]

static ASPOSECPP_SHARED_API int64_t System::Threading::Interlocked::ExchangeAdd ( int64_t &  location1,
int64_t  value 
)
static

Increases value atomically via exchange-add procedure.

Parameters
location1Variable reference to increase.
valueValue to add to location1.
Returns
Value of variable right after it was increased.

◆ Increment() [1/2]

static int32_t System::Threading::Interlocked::Increment ( int32_t &  location)
inlinestatic

Increments value atomically.

Parameters
locationVariable reference to increment.
Returns
Value of variable right after it was incremented.

◆ Increment() [2/2]

static int64_t System::Threading::Interlocked::Increment ( int64_t &  location)
inlinestatic

Increments value atomically.

Parameters
locationVariable reference to increment.
Returns
Value of variable right after it was incremented.