56 #ifndef LLVM_ADT_INTRUSIVEREFCNTPTR_H
57 #define LLVM_ADT_INTRUSIVEREFCNTPTR_H
72 mutable unsigned RefCount = 0;
80 assert(RefCount > 0 &&
"Reference count is already zero.");
82 delete static_cast<const Derived *
>(
this);
88 mutable std::atomic<int> RefCount;
94 void Retain()
const { RefCount.fetch_add(1, std::memory_order_relaxed); }
97 int NewRefCount = RefCount.fetch_sub(1, std::memory_order_acq_rel) - 1;
98 assert(NewRefCount >= 0 &&
"Reference count was already zero.");
100 delete static_cast<const Derived *
>(
this);
165 T *
get()
const {
return Obj; }
166 explicit operator bool()
const {
return Obj; }
194 template <
class T,
class U>
197 return A.
get() == B.
get();
200 template <
class T,
class U>
203 return A.
get() != B.
get();
206 template <
class T,
class U>
211 template <
class T,
class U>
216 template <
class T,
class U>
221 template <
class T,
class U>
248 template <
typename From>
struct simplify_type;
266 #endif // LLVM_ADT_INTRUSIVEREFCNTPTR_H
static SimpleType getSimplifiedValue(const IntrusiveRefCntPtr< T > &Val)
IntrusiveRefCntPtr()=default
Class you can specialize to provide custom retain/release functionality for a type.
A CRTP mixin class that adds reference counting to a type.
RefCountedBase(const RefCountedBase &)
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
ThreadSafeRefCountedBase()
static void release(T *obj)
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
static void retain(T *obj)
A thread-safe version of RefCountedBase.
IntrusiveRefCntPtr(const IntrusiveRefCntPtr &S)
bool operator!=(uint64_t V1, const APInt &V2)
IntrusiveRefCntPtr(T *obj)
void swap(IntrusiveRefCntPtr &other)
static SimpleType getSimplifiedValue(IntrusiveRefCntPtr< T > &Val)
IntrusiveRefCntPtr(const IntrusiveRefCntPtr< X > &S)
IntrusiveRefCntPtr(IntrusiveRefCntPtr &&S)
void resetWithoutRelease()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator==(uint64_t V1, const APInt &V2)
IntrusiveRefCntPtr & operator=(IntrusiveRefCntPtr S)
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
IntrusiveRefCntPtr(IntrusiveRefCntPtr< X > &&S)