Module |
|
Header |
/Engine/Source/Runtime/Core/Public/Templates/Atomic.h |
Include |
#include "Templates/Atomic.h" |
bool CompareExchange
(
T & Expected,
T Value
)
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.
Parameter |
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. |