13 #ifndef __UT_COWVALUE_H__
14 #define __UT_COWVALUE_H__
36 template <
typename... Args>
38 :
myRep(new Rep(std::in_place, std::forward<Args>(
args)...))
167 inline const static exint IMMORTAL_REF_COUNT = -1;
172 Rep() : myData{}, myRefCount(1) {}
175 template <
typename... Args>
177 : myData(std::forward<Args>(
args)...), myRefCount(1)
182 explicit Rep(ImmortalTag) : myData{}, myRefCount{IMMORTAL_REF_COUNT} {}
186 Rep(
const Rep &other) =
delete;
197 return myRefCount.
relaxedLoad() == IMMORTAL_REF_COUNT;
205 const T *
data()
const {
return &myData; }
211 static const Rep theInstance{ImmortalTag{}};
257 template <
typename T>
258 struct DefaultClearer;
260 template <
typename S>
269 static const bool clearNeedsDestruction =
false;
273 #endif // __UT_COWVALUE_H__
static void clearConstruct(UT_COWValue< S > *p)
UT_COWValue & operator=(const UT_COWValue &other)
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
Rep(std::in_place_t, Args &&...args)
static const UT_COWValue< T > & getStaticEmpty()
static const Rep * getStaticEmpty()
static void clear(UT_COWValue< S > &v)
constexpr SYS_MemoryOrder SYS_MEMORY_ORDER_ACQ_REL
UT_COWValue(UT_COWValue &&other) noexcept
#define utZoneScopedN(name)
UT_COWValue & operator=(UT_COWValue &&other) noexcept
const T * operator->() const
T load(SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST) const
UT_COWValue(const UT_COWValue &other)
UT_COWValue(std::in_place_t, Args &&...args)
constexpr SYS_MemoryOrder SYS_MEMORY_ORDER_RELAXED
Any reordering the compiler or hardware chooses to do is okay.
SYS_FORCE_INLINE T relaxedLoad() const
VULKAN_HPP_CONSTEXPR_14 VULKAN_HPP_INLINE T exchange(T &obj, U &&newValue)
**If you just want to fire and args
T add(T val)
Atomically adds val to myValue, returning the new value of myValue.
Rep & operator=(const Rep &other)=delete
const T & operator*() const
void swap(UT_COWValue< T > &other)
constexpr SYS_MemoryOrder SYS_MEMORY_ORDER_ACQUIRE
static bool isClear(const UT_COWValue< S > &v)