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.cpp | |
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.cpp')
-rw-r--r-- | library/cpp/coroutine/engine/stack/stack.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/library/cpp/coroutine/engine/stack/stack.cpp b/library/cpp/coroutine/engine/stack/stack.cpp index e29450261d..658f263216 100644 --- a/library/cpp/coroutine/engine/stack/stack.cpp +++ b/library/cpp/coroutine/engine/stack/stack.cpp @@ -1,67 +1,67 @@ -#include "stack.h" - -#include "stack_allocator.h" -#include "stack_guards.h" - - -namespace NCoro::NStack { - -namespace NDetails { - - TStack::TStack(void* rawMemory, void* alignedMemory, uint64_t alignedSize, const char* /*name*/) - : RawMemory_((char*)rawMemory) - , AlignedMemory_((char*)alignedMemory) - , Size_(alignedSize) - { - Y_ASSERT(AlignedMemory_ && RawMemory_ && Size_); - Y_ASSERT(!(Size_ & PageSizeMask)); - Y_ASSERT(!((uint64_t)AlignedMemory_ & PageSizeMask)); - } - - TStack::TStack(TStack&& rhs) noexcept - : RawMemory_(rhs.RawMemory_) - , AlignedMemory_(rhs.AlignedMemory_) - , Size_(rhs.Size_) - { - rhs.Reset(); - } - - TStack& TStack::operator=(TStack&& rhs) noexcept { - std::swap(*this, rhs); - rhs.Reset(); - return *this; - } - - void TStack::Reset() noexcept { - Y_ASSERT(AlignedMemory_ && RawMemory_ && Size_); - - RawMemory_ = nullptr; - AlignedMemory_ = nullptr; - Size_ = 0; - } - -} // namespace NDetails - - - TStackHolder::TStackHolder(NStack::IAllocator& allocator, uint32_t size, const char* name) noexcept - : Allocator_(allocator) - , Stack_(Allocator_.AllocStack(size, name)) - {} - - TStackHolder::~TStackHolder() { - Allocator_.FreeStack(Stack_); - } - - TArrayRef<char> TStackHolder::Get() noexcept { - return Allocator_.GetStackWorkspace(Stack_.GetAlignedMemory(), Stack_.GetSize()); - } - - bool TStackHolder::LowerCanaryOk() const noexcept { - return Allocator_.CheckStackOverflow(Stack_.GetAlignedMemory()); - } - - bool TStackHolder::UpperCanaryOk() const noexcept { - return Allocator_.CheckStackOverride(Stack_.GetAlignedMemory(), Stack_.GetSize()); - } - -} +#include "stack.h" + +#include "stack_allocator.h" +#include "stack_guards.h" + + +namespace NCoro::NStack { + +namespace NDetails { + + TStack::TStack(void* rawMemory, void* alignedMemory, uint64_t alignedSize, const char* /*name*/) + : RawMemory_((char*)rawMemory) + , AlignedMemory_((char*)alignedMemory) + , Size_(alignedSize) + { + Y_ASSERT(AlignedMemory_ && RawMemory_ && Size_); + Y_ASSERT(!(Size_ & PageSizeMask)); + Y_ASSERT(!((uint64_t)AlignedMemory_ & PageSizeMask)); + } + + TStack::TStack(TStack&& rhs) noexcept + : RawMemory_(rhs.RawMemory_) + , AlignedMemory_(rhs.AlignedMemory_) + , Size_(rhs.Size_) + { + rhs.Reset(); + } + + TStack& TStack::operator=(TStack&& rhs) noexcept { + std::swap(*this, rhs); + rhs.Reset(); + return *this; + } + + void TStack::Reset() noexcept { + Y_ASSERT(AlignedMemory_ && RawMemory_ && Size_); + + RawMemory_ = nullptr; + AlignedMemory_ = nullptr; + Size_ = 0; + } + +} // namespace NDetails + + + TStackHolder::TStackHolder(NStack::IAllocator& allocator, uint32_t size, const char* name) noexcept + : Allocator_(allocator) + , Stack_(Allocator_.AllocStack(size, name)) + {} + + TStackHolder::~TStackHolder() { + Allocator_.FreeStack(Stack_); + } + + TArrayRef<char> TStackHolder::Get() noexcept { + return Allocator_.GetStackWorkspace(Stack_.GetAlignedMemory(), Stack_.GetSize()); + } + + bool TStackHolder::LowerCanaryOk() const noexcept { + return Allocator_.CheckStackOverflow(Stack_.GetAlignedMemory()); + } + + bool TStackHolder::UpperCanaryOk() const noexcept { + return Allocator_.CheckStackOverride(Stack_.GetAlignedMemory(), Stack_.GetSize()); + } + +} |