I3DHAsyncTaskFence.h Source File

I3DHAsyncTaskFence.h Source File#

instant3Dhub: I3DHAsyncTaskFence.h Source File
instant3Dhub
I3DHAsyncTaskFence.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <atomic>
9
10#include "CoreMinimal.h"
11
13
25class FI3DHAsyncTaskFence
26{
27public:
28 uint32 AddRef() const { return NumRefs.fetch_add(1, std::memory_order_relaxed) + 1; }
29
30 uint32 Release() const
31 {
32 const uint32 Refs = NumRefs.fetch_sub(1, std::memory_order_acq_rel) - 1;
33 if (Refs == 0)
34 {
35 delete this;
36 }
37 return Refs;
38 }
39
40 uint32 GetRefCount() const { return NumRefs.load(std::memory_order_relaxed); }
41
42private:
43 mutable std::atomic<uint32> NumRefs{0};
44};
45