aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/use_count_checker.h
blob: 9e008f0c2203d2cd2e3a220b180e4bac4d55e45d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include <util/generic/refcount.h>

class TUseCountChecker {
private:
    TAtomicCounter Counter;
 
public:
    TUseCountChecker();
    ~TUseCountChecker();
    void Inc();
    void Dec();
};

class TUseCountHolder {
private:
    TUseCountChecker* CurrentChecker;
 
public:
    TUseCountHolder();
    explicit TUseCountHolder(TUseCountChecker* currentChecker);
    TUseCountHolder& operator=(TUseCountHolder that);
    ~TUseCountHolder();
    void Swap(TUseCountHolder&);
    void Reset();
};