System::Threading::Interlocked::CompareExchange method

Interlocked::CompareExchange(int32_t&, int32_t, int32_t, bool&) method

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

static int32_t System::Threading::Interlocked::CompareExchange(int32_t &location1, int32_t value, int32_t comparand, bool &succeeded)
ParameterTypeDescription
location1int32_t&Variable reference to change.
valueint32_tValue to store.
comparandint32_tValue to compare variable’s value to before exchanging.
succeededbool&Reference to variable which is set to true if exchange took place and to false otherwise.

ReturnValue

Value of variable on operation start regardless whether it was changed or not.

See Also

Interlocked::CompareExchange(T&, T, T) method

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

template<typename T> static std::enable_if<IsSupportedInt<T>, T>::type System::Threading::Interlocked::CompareExchange(T &location1, T value, T comparand)
ParameterDescription
TVariable type.
ParameterTypeDescription
location1T&Variable reference to change.
valueTValue to store.
comparandTValue to compare variable’s value to before exchanging.

ReturnValue

Value of variable on operation start regardless whether it was changed or not.

See Also

Interlocked::CompareExchange(T&, T, T) method

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<typename T> static std::enable_if<!IsSupportedInt<T>, T>::type System::Threading::Interlocked::CompareExchange(T &location1, T value, T comparand)
ParameterDescription
TVariable type.
ParameterTypeDescription
location1T&Variable reference to change.
valueTValue to store.
comparandTValue to compare variable’s value to before exchanging.

ReturnValue

Value of variable on operation start regardless whether it was changed or not.

See Also