aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/util/memory_track.cpp
blob: 5f422116beeba3198bec58eb3d85fb15186633bf (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
28
29
30
31
32
33
34
35
36
37
38
#include "memory_track.h"
#include "memory_tracker.h"

namespace NActors {
namespace NMemory {

namespace NPrivate {

TThreadLocalInfo::TThreadLocalInfo()
    : Metrics(TMemoryTracker::Instance()->GetCount())
{
    TMemoryTracker::Instance()->OnCreateThread(this);
}

TThreadLocalInfo::~TThreadLocalInfo() {
    TMemoryTracker::Instance()->OnDestroyThread(this);
}

TMetric* TThreadLocalInfo::GetMetric(size_t index) {
    if (Y_UNLIKELY(index >= Metrics.size())) {
        return &Null;
    }
    return &Metrics[index];
}

const std::vector<TMetric>& TThreadLocalInfo::GetMetrics() const {
    return Metrics;
}

size_t TBaseLabel::RegisterStaticMemoryLabel(const char* name, bool hasSensor) {
    return TMemoryTracker::Instance()->RegisterStaticMemoryLabel(name, hasSensor);
}

}

}
}