ysafeptr.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #include "ysafeptr.h"
  2. #ifdef CHECK_YPTR2
  3. Y_POD_THREAD(bool)
  4. IObjectBase::DisableThreadCheck;
  5. #endif
  6. ////////////////////////////////////////////////////////////////////////////////////////////////////
  7. void IObjectBase::ReleaseObjComplete(int nMask) {
  8. if ((ObjData & 0x3fffffff) == 0 && RefData == 0) {
  9. assert((ObjData & 0x40000000) == 0); // object not being invalidated
  10. delete this;
  11. } else if ((ObjData & nMask) == 0) {
  12. if (ObjData & 0x40000000) {
  13. // object is already being invalidated
  14. // possible when no CObj left and object is invalidated and during this all CMObj are also out
  15. return;
  16. }
  17. ObjData |= 0xc0000000;
  18. AddRef();
  19. DestroyContents();
  20. assert((ObjData & nMask) == 0); // otherwise empty constructor is adding CObjs on self
  21. ObjData &= ~0x40000000;
  22. ReleaseRef();
  23. }
  24. }
  25. ////////////////////////////////////////////////////////////////////////////////////////////////////
  26. void IObjectBase::ReleaseRefComplete() {
  27. assert(RefData == 0);
  28. if ((ObjData & 0x3fffffff) == 0) {
  29. assert((ObjData & 0x40000000) == 0); // object not being invalidated
  30. delete this;
  31. }
  32. }