perf(templates): optimize the performance of TAtomic::FetchFn()
This commit is contained in:
parent
4f4a351316
commit
b7c3ffd0fb
@ -151,7 +151,8 @@ public:
|
||||
FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent)
|
||||
{
|
||||
ValueType Temp(Load(EMemoryOrder::Relaxed));
|
||||
while (!CompareExchange(Temp, InvokeResult<ValueType>(Forward<F>(Func), Temp), Order));
|
||||
// We do a weak read here because we require a loop.
|
||||
while (!CompareExchange(Temp, InvokeResult<ValueType>(Forward<F>(Func), Temp), Order, true));
|
||||
return Temp;
|
||||
}
|
||||
|
||||
@ -160,7 +161,8 @@ public:
|
||||
FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile
|
||||
{
|
||||
ValueType Temp(Load(EMemoryOrder::Relaxed));
|
||||
while (!CompareExchange(Temp, InvokeResult<ValueType>(Forward<F>(Func), Temp), Order));
|
||||
// We do a weak read here because we require a loop.
|
||||
while (!CompareExchange(Temp, InvokeResult<ValueType>(Forward<F>(Func), Temp), Order, true));
|
||||
return Temp;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user