diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/ysafeptr.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/ysafeptr.cpp')
-rw-r--r-- | util/ysafeptr.cpp | 33 |
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; + } +} |