59 typedef void (*UniqueChangedFuncPtr)(
TfRefBase const *, bool);
60 struct UniqueChangedListener {
62 UniqueChangedFuncPtr func;
84 return std::abs(_refCount.load(std::memory_order_relaxed));
92 void SetShouldInvokeUniqueChangedListener(
bool shouldCall) {
93 int curValue = _refCount.load(std::memory_order_relaxed);
94 while ((curValue > 0 && shouldCall) ||
95 (curValue < 0 && !shouldCall)) {
96 if (_refCount.compare_exchange_weak(curValue, -curValue)) {
102 TF_API
static void SetUniqueChangedListener(UniqueChangedListener listener);
112 std::atomic_int &_GetRefCount()
const {
119 mutable std::atomic_int _refCount;
121 static UniqueChangedListener _uniqueChangedListener;
122 template <
typename T>
friend class TfRefPtr;
123 friend struct Tf_RefPtr_UniqueChangedCounter;
124 friend struct Tf_RefPtr_Counter;