aboutsummaryrefslogtreecommitdiffstats
path: root/util/ysafeptr.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/ysafeptr.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/ysafeptr.cpp')
-rw-r--r--util/ysafeptr.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/ysafeptr.cpp b/util/ysafeptr.cpp
new file mode 100644
index 0000000000..96f2514067
--- /dev/null
+++ b/util/ysafeptr.cpp
@@ -0,0 +1,33 @@
+#include "ysafeptr.h"
+
+#ifdef CHECK_YPTR2
+Y_POD_THREAD(bool)
+IObjectBase::DisableThreadCheck;
+#endif
+////////////////////////////////////////////////////////////////////////////////////////////////////
+void IObjectBase::ReleaseObjComplete(int nMask) {
+ if ((ObjData & 0x3fffffff) == 0 && RefData == 0) {
+ assert((ObjData & 0x40000000) == 0); // object not being invalidated
+ delete this;
+ } else if ((ObjData & nMask) == 0) {
+ if (ObjData & 0x40000000) {
+ // object is already being invalidated
+ // possible when no CObj left and object is invalidated and during this all CMObj are also out
+ return;
+ }
+ ObjData |= 0xc0000000;
+ AddRef();
+ DestroyContents();
+ assert((ObjData & nMask) == 0); // otherwise empty constructor is adding CObjs on self
+ ObjData &= ~0x40000000;
+ ReleaseRef();
+ }
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+void IObjectBase::ReleaseRefComplete() {
+ assert(RefData == 0);
+ if ((ObjData & 0x3fffffff) == 0) {
+ assert((ObjData & 0x40000000) == 0); // object not being invalidated
+ delete this;
+ }
+}