diff options
author | alexeylaptev <alexeylaptev@yandex-team.ru> | 2022-02-10 16:50:06 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:06 +0300 |
commit | 3106abc0443cda789ce4968aeee63d3a8fcc7d85 (patch) | |
tree | ec44b9884cc11c2a7b4f4dc7fd36a1ae1ba2d3db /library/cpp/coroutine/engine/stack/stack_pool.h | |
parent | a76f5e1efe665e1bb125f05ae275b2a6226517d9 (diff) | |
download | ydb-3106abc0443cda789ce4968aeee63d3a8fcc7d85.tar.gz |
Restoring authorship annotation for <alexeylaptev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/coroutine/engine/stack/stack_pool.h')
-rw-r--r-- | library/cpp/coroutine/engine/stack/stack_pool.h | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/library/cpp/coroutine/engine/stack/stack_pool.h b/library/cpp/coroutine/engine/stack/stack_pool.h index 27a8e9394b..0625362d4d 100644 --- a/library/cpp/coroutine/engine/stack/stack_pool.h +++ b/library/cpp/coroutine/engine/stack/stack_pool.h @@ -1,54 +1,54 @@ -#pragma once - -#include "stack.h" -#include "stack_common.h" - -#include <util/generic/noncopyable.h> -#include <util/generic/ptr.h> -#include <util/generic/vector.h> - - -namespace NCoro::NStack { - - class IGuard; - class TStorage; - struct TPoolAllocatorSettings; - - template<typename TGuard> - class TPool final : private TMoveOnly { - struct TMemory { - char* Raw = nullptr; - char* Aligned = nullptr; // points to aligned memory, which includes space for first page guard - }; - public: - TPool(uint64_t stackSize, const TPoolAllocatorSettings& settings, const TGuard& guard); - TPool(TPool&& other) noexcept; - ~TPool(); - - NDetails::TStack AllocStack(const char* name); - void FreeStack(NDetails::TStack& stack); - - uint64_t GetReleasedSize() const noexcept; - uint64_t GetFullSize() const noexcept; - uint64_t GetNumOfAllocated() const noexcept { return NumOfAllocated_; } - - private: - void AllocNewMemoryChunk(); - bool IsSmallStack() const noexcept; - bool IsStackFromThisPool(const NDetails::TStack& stack) const noexcept; - NDetails::TStack AllocNewStack(const char* name); - - private: - const uint64_t StackSize_ = 0; - uint64_t RssPagesToKeep_ = 0; - const TGuard& Guard_; - TVector<TMemory> Memory_; // memory chunks - THolder<TStorage> Storage_; - char* NextToAlloc_ = nullptr; // points to next available stack in the last memory chunk - const uint64_t ChunkSize_ = 0; - uint64_t NumOfAllocated_ = 0; - }; - -} - -#include "stack_pool.inl" +#pragma once + +#include "stack.h" +#include "stack_common.h" + +#include <util/generic/noncopyable.h> +#include <util/generic/ptr.h> +#include <util/generic/vector.h> + + +namespace NCoro::NStack { + + class IGuard; + class TStorage; + struct TPoolAllocatorSettings; + + template<typename TGuard> + class TPool final : private TMoveOnly { + struct TMemory { + char* Raw = nullptr; + char* Aligned = nullptr; // points to aligned memory, which includes space for first page guard + }; + public: + TPool(uint64_t stackSize, const TPoolAllocatorSettings& settings, const TGuard& guard); + TPool(TPool&& other) noexcept; + ~TPool(); + + NDetails::TStack AllocStack(const char* name); + void FreeStack(NDetails::TStack& stack); + + uint64_t GetReleasedSize() const noexcept; + uint64_t GetFullSize() const noexcept; + uint64_t GetNumOfAllocated() const noexcept { return NumOfAllocated_; } + + private: + void AllocNewMemoryChunk(); + bool IsSmallStack() const noexcept; + bool IsStackFromThisPool(const NDetails::TStack& stack) const noexcept; + NDetails::TStack AllocNewStack(const char* name); + + private: + const uint64_t StackSize_ = 0; + uint64_t RssPagesToKeep_ = 0; + const TGuard& Guard_; + TVector<TMemory> Memory_; // memory chunks + THolder<TStorage> Storage_; + char* NextToAlloc_ = nullptr; // points to next available stack in the last memory chunk + const uint64_t ChunkSize_ = 0; + uint64_t NumOfAllocated_ = 0; + }; + +} + +#include "stack_pool.inl" |