aboutsummaryrefslogtreecommitdiffstats
path: root/util/memory/pool.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/memory/pool.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/memory/pool.cpp')
-rw-r--r--util/memory/pool.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/util/memory/pool.cpp b/util/memory/pool.cpp
index b3144aefc3..9a011f0e4f 100644
--- a/util/memory/pool.cpp
+++ b/util/memory/pool.cpp
@@ -1,55 +1,55 @@
-#include "pool.h"
-
+#include "pool.h"
+
TMemoryPool::IGrowPolicy* TMemoryPool::TLinearGrow::Instance() noexcept {
- return SingletonWithPriority<TLinearGrow, 0>();
-}
-
+ return SingletonWithPriority<TLinearGrow, 0>();
+}
+
TMemoryPool::IGrowPolicy* TMemoryPool::TExpGrow::Instance() noexcept {
- return SingletonWithPriority<TExpGrow, 0>();
-}
-
-void TMemoryPool::AddChunk(size_t hint) {
- const size_t dataLen = Max(BlockSize_, hint);
+ return SingletonWithPriority<TExpGrow, 0>();
+}
+
+void TMemoryPool::AddChunk(size_t hint) {
+ const size_t dataLen = Max(BlockSize_, hint);
size_t allocSize = dataLen + sizeof(TChunk);
if (Options_.RoundUpToNextPowerOfTwo) {
allocSize = FastClp2(allocSize);
}
TBlock nb = Alloc_->Allocate(allocSize);
-
+
// Add previous chunk's stats
if (Current_ != &Empty_) {
MemoryAllocatedBeforeCurrent_ += Current_->Used();
MemoryWasteBeforeCurrent_ += Current_->Left();
}
- BlockSize_ = GrowPolicy_->Next(dataLen);
- Current_ = new (nb.Data) TChunk(nb.Len - sizeof(TChunk));
- Chunks_.PushBack(Current_);
-}
-
-void TMemoryPool::DoClear(bool keepfirst) noexcept {
- while (!Chunks_.Empty()) {
- TChunk* c = Chunks_.PopBack();
-
- if (keepfirst && Chunks_.Empty()) {
- c->ResetChunk();
- Chunks_.PushBack(c);
- Current_ = c;
- BlockSize_ = c->BlockLength() - sizeof(TChunk);
- MemoryAllocatedBeforeCurrent_ = 0;
+ BlockSize_ = GrowPolicy_->Next(dataLen);
+ Current_ = new (nb.Data) TChunk(nb.Len - sizeof(TChunk));
+ Chunks_.PushBack(Current_);
+}
+
+void TMemoryPool::DoClear(bool keepfirst) noexcept {
+ while (!Chunks_.Empty()) {
+ TChunk* c = Chunks_.PopBack();
+
+ if (keepfirst && Chunks_.Empty()) {
+ c->ResetChunk();
+ Chunks_.PushBack(c);
+ Current_ = c;
+ BlockSize_ = c->BlockLength() - sizeof(TChunk);
+ MemoryAllocatedBeforeCurrent_ = 0;
MemoryWasteBeforeCurrent_ = 0;
- return;
- }
-
- TBlock b = {c, c->BlockLength()};
-
- c->~TChunk();
- Alloc_->Release(b);
- }
-
- Current_ = &Empty_;
- BlockSize_ = Origin_;
+ return;
+ }
+
+ TBlock b = {c, c->BlockLength()};
+
+ c->~TChunk();
+ Alloc_->Release(b);
+ }
+
+ Current_ = &Empty_;
+ BlockSize_ = Origin_;
MemoryAllocatedBeforeCurrent_ = 0;
MemoryWasteBeforeCurrent_ = 0;
-}
+}