Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Templates > API/Runtime/Core/Templates/TAtomicBase_Basic
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Templates/Atomic.h |
Include | #include "Templates/Atomic.h" |
bool CompareExchange
&40;
T & Expected,
T Value
&41;
Remarks
Compares the element with an expected value and, only if comparison succeeds, assigns the element to a new value. The previous value is copied into Expected in any case.
It is equivalent to this in non-atomic terms: bool CompareExchange(T& Expected, T Value) { bool bResult = this->Element == Expected; Expected = this->Element; if (bResult) { this->Element = Value; } return bResult; }Compares the element with an expected value and, only if comparison succeeds, assigns the element to a new value. The previous value is copied into Expected in any case.
It is equivalent to this in non-atomic terms: bool CompareExchange(T& Expected, T Value) { bool bResult = this->Element == Expected; Expected = this->Element; if (bResult) { this->Element = Value; } return bResult; } Whether the element compared equal to Expected.
Parameters
Name | Description |
---|---|
Expected | The value to compare to the element, and will hold the existing value of the element after returning. |
Value | The value to assign, only if Expected matches the element. |
Expected | The value to compare to the element, and will hold the existing value of the element after returning. |
Value | The value to assign, only if Expected matches the element. |