MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ~FancyRefPtr

Method ~FancyRefPtr

Kernel/include/refptr.h:64–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 }
63
64 virtual ~FancyRefPtr(){
65 if(refCount && obj){
66 if(*refCount > 0){
67 __sync_fetch_and_sub(refCount, 1);
68 } else {
69 return; // Another thread deleting?
70 }
71 } else {
72 return;
73 }
74
75 #ifdef REFPTR_ASSERTIONS
76 assert(refCount);
77 #endif
78
79 #ifdef REFPTR_DEBUG
80 Log::Info("RefPtr: %s object unreferenced, %d references to object", TTraits<T>::name(), *refCount);
81 #endif
82
83 if((*refCount) <= 0){
84 delete refCount;
85 delete obj;
86
87 #ifdef REFPTR_DEBUG
88 Log::Info("RefPtr: Deleting object");
89 #endif
90 }
91 }
92
93 inline T* get() const { return obj; }
94 inline unsigned* getRefCount() const { return refCount; }

Callers

nothing calls this directly

Calls 1

InfoFunction · 0.85

Tested by

no test coverage detected