diff options
author | Ruslan Kovalev <ruslan.a.kovalev@gmail.com> | 2022-02-10 16:46:44 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:44 +0300 |
commit | 59e19371de37995fcb36beb16cd6ec030af960bc (patch) | |
tree | fa68e36093ebff8b805462e9e6d331fe9d348214 /library/cpp/coroutine/engine/trampoline.h | |
parent | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff) | |
download | ydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz |
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/coroutine/engine/trampoline.h')
-rw-r--r-- | library/cpp/coroutine/engine/trampoline.h | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/library/cpp/coroutine/engine/trampoline.h b/library/cpp/coroutine/engine/trampoline.h index 37b61cf015..5ece7873b0 100644 --- a/library/cpp/coroutine/engine/trampoline.h +++ b/library/cpp/coroutine/engine/trampoline.h @@ -1,60 +1,60 @@ -#pragma once +#pragma once #include "stack/stack_common.h" #include "stack/stack.h" -#include <util/generic/noncopyable.h> -#include <util/generic/ptr.h> +#include <util/generic/noncopyable.h> +#include <util/generic/ptr.h> #include <util/system/context.h> #include <util/system/defaults.h> -#if !defined(STACK_GROW_DOWN) -# error "unsupported" -#endif - +#if !defined(STACK_GROW_DOWN) +# error "unsupported" +#endif + class TCont; -typedef void (*TContFunc)(TCont*, void*); - -namespace NCoro { +typedef void (*TContFunc)(TCont*, void*); +namespace NCoro { + namespace NStack { class IAllocator; - } - - class TTrampoline : public ITrampoLine, TNonCopyable { - public: + } + + class TTrampoline : public ITrampoLine, TNonCopyable { + public: typedef std::function<void (TCont*)> TFunc; - TTrampoline( + TTrampoline( NCoro::NStack::IAllocator& allocator, uint32_t stackSize, TFunc f, TCont* cont - ) noexcept; - - TArrayRef<char> Stack() noexcept; + ) noexcept; - TExceptionSafeContext* Context() noexcept { - return &Ctx_; - } + TArrayRef<char> Stack() noexcept; - void SwitchTo(TExceptionSafeContext* ctx) noexcept { + TExceptionSafeContext* Context() noexcept { + return &Ctx_; + } + + void SwitchTo(TExceptionSafeContext* ctx) noexcept { Y_VERIFY(Stack_.LowerCanaryOk(), "Stack overflow (%s)", ContName()); Y_VERIFY(Stack_.UpperCanaryOk(), "Stack override (%s)", ContName()); - Ctx_.SwitchTo(ctx); - } - + Ctx_.SwitchTo(ctx); + } + void DoRun() override; - + void DoRunNaked() override; - private: + private: const char* ContName() const noexcept; private: NStack::TStackHolder Stack_; - const TContClosure Clo_; - TExceptionSafeContext Ctx_; + const TContClosure Clo_; + TExceptionSafeContext Ctx_; TFunc Func_; - TCont* const Cont_; + TCont* const Cont_; }; } |