blob: 5b94b2126f16236091438f16a12a233c2a107cc7 (
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
39
40
|
#pragma once
#include "thread_extra.h"
#include <util/generic/vector.h>
#include <util/system/yassert.h>
template <typename T, typename TTag = void, template <typename, class> class TVectorType = TVector>
class TTempTlsVector {
private:
struct TTagForTls {};
TVectorType<T, std::allocator<T>>* Vector;
public:
TVectorType<T, std::allocator<T>>* GetVector() {
return Vector;
}
TTempTlsVector() {
Vector = FastTlsSingletonWithTag<TVectorType<T, std::allocator<T>>, TTagForTls>();
Y_ASSERT(Vector->empty());
}
~TTempTlsVector() {
Clear();
}
void Clear() {
Vector->clear();
}
size_t Capacity() const noexcept {
return Vector->capacity();
}
void Shrink() {
Vector->shrink_to_fit();
}
};
|