blob: ec9041cb152dc336d0ef1ee66338c31db64bddb7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#pragma once
#include <util/generic/noncopyable.h>
#include <util/system/atomic.h>
#include <util/system/yassert.h>
class TAllocCounter : TNonCopyable {
private:
TAtomic* CountPtr;
public:
TAllocCounter(TAtomic* countPtr)
: CountPtr(countPtr)
{
AtomicIncrement(*CountPtr);
}
~TAllocCounter() {
Y_VERIFY(AtomicDecrement(*CountPtr) >= 0, "released too many");
}
};
|