aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/use_count_checker.h
blob: 70bef6fa8a320b19d397ae49647f93e55b9ec31a (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();
};