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.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.h')
-rw-r--r-- | library/cpp/coroutine/engine/stack/stack.h | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/library/cpp/coroutine/engine/stack/stack.h b/library/cpp/coroutine/engine/stack/stack.h index 7d98ba4c68..e6b9a3a05d 100644 --- a/library/cpp/coroutine/engine/stack/stack.h +++ b/library/cpp/coroutine/engine/stack/stack.h @@ -1,77 +1,77 @@ -#pragma once - -#include <util/generic/array_ref.h> -#include <util/generic/fwd.h> -#include <util/generic/noncopyable.h> - -#include <cstdint> - - -namespace NCoro::NStack { - - class IAllocator; - -namespace NDetails { - - //! Do not use directly, use TStackHolder instead - class TStack final : private TMoveOnly { - public: - /*! rawMemory: can be used by unaligned allocator to free stack memory after use - * alignedMemory: pointer to aligned memory on which stack workspace and guard are actually placed - * alignedSize: size of workspace memory + memory for guard - * guard: guard to protect this stack - * name: name of coroutine for which this stack is allocated - */ - TStack(void* rawMemory, void* alignedMemory, uint64_t alignedSize, const char* name); - TStack(TStack&& rhs) noexcept; - TStack& operator=(TStack&& rhs) noexcept; - - char* GetRawMemory() const noexcept { - return RawMemory_; - } - - char* GetAlignedMemory() const noexcept { - return AlignedMemory_; - } - - //! Stack size (includes memory for guard) - uint64_t GetSize() const noexcept { - return Size_; - } - - //! Resets parameters, should be called after stack memory is freed - void Reset() noexcept; - - private: - char* RawMemory_ = nullptr; // not owned - char* AlignedMemory_ = nullptr; // not owned - uint64_t Size_ = 0; - }; - -} // namespace NDetails - - class TStackHolder final : private TMoveOnly { - public: - explicit TStackHolder(IAllocator& allocator, uint32_t size, const char* name) noexcept; - TStackHolder(TStackHolder&&) = default; - TStackHolder& operator=(TStackHolder&&) = default; - - ~TStackHolder(); - - char* GetAlignedMemory() const noexcept { - return Stack_.GetAlignedMemory(); - } - uint64_t GetSize() const noexcept { - return Stack_.GetSize(); - } - - TArrayRef<char> Get() noexcept; - bool LowerCanaryOk() const noexcept; - bool UpperCanaryOk() const noexcept; - - private: - IAllocator& Allocator_; - NDetails::TStack Stack_; - }; - -} +#pragma once + +#include <util/generic/array_ref.h> +#include <util/generic/fwd.h> +#include <util/generic/noncopyable.h> + +#include <cstdint> + + +namespace NCoro::NStack { + + class IAllocator; + +namespace NDetails { + + //! Do not use directly, use TStackHolder instead + class TStack final : private TMoveOnly { + public: + /*! rawMemory: can be used by unaligned allocator to free stack memory after use + * alignedMemory: pointer to aligned memory on which stack workspace and guard are actually placed + * alignedSize: size of workspace memory + memory for guard + * guard: guard to protect this stack + * name: name of coroutine for which this stack is allocated + */ + TStack(void* rawMemory, void* alignedMemory, uint64_t alignedSize, const char* name); + TStack(TStack&& rhs) noexcept; + TStack& operator=(TStack&& rhs) noexcept; + + char* GetRawMemory() const noexcept { + return RawMemory_; + } + + char* GetAlignedMemory() const noexcept { + return AlignedMemory_; + } + + //! Stack size (includes memory for guard) + uint64_t GetSize() const noexcept { + return Size_; + } + + //! Resets parameters, should be called after stack memory is freed + void Reset() noexcept; + + private: + char* RawMemory_ = nullptr; // not owned + char* AlignedMemory_ = nullptr; // not owned + uint64_t Size_ = 0; + }; + +} // namespace NDetails + + class TStackHolder final : private TMoveOnly { + public: + explicit TStackHolder(IAllocator& allocator, uint32_t size, const char* name) noexcept; + TStackHolder(TStackHolder&&) = default; + TStackHolder& operator=(TStackHolder&&) = default; + + ~TStackHolder(); + + char* GetAlignedMemory() const noexcept { + return Stack_.GetAlignedMemory(); + } + uint64_t GetSize() const noexcept { + return Stack_.GetSize(); + } + + TArrayRef<char> Get() noexcept; + bool LowerCanaryOk() const noexcept; + bool UpperCanaryOk() const noexcept; + + private: + IAllocator& Allocator_; + NDetails::TStack Stack_; + }; + +} |