use_count_checker.h 505 B

123456789101112131415161718192021222324252627
  1. #pragma once
  2. #include <util/generic/refcount.h>
  3. class TUseCountChecker {
  4. private:
  5. TAtomicCounter Counter;
  6. public:
  7. TUseCountChecker();
  8. ~TUseCountChecker();
  9. void Inc();
  10. void Dec();
  11. };
  12. class TUseCountHolder {
  13. private:
  14. TUseCountChecker* CurrentChecker;
  15. public:
  16. TUseCountHolder();
  17. explicit TUseCountHolder(TUseCountChecker* currentChecker);
  18. TUseCountHolder& operator=(TUseCountHolder that);
  19. ~TUseCountHolder();
  20. void Swap(TUseCountHolder&);
  21. void Reset();
  22. };