diff options
author | Ruslan Kovalev <ruslan.a.kovalev@gmail.com> | 2022-02-10 16:46:45 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:45 +0300 |
commit | 9123176b341b6f2658cff5132482b8237c1416c8 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/coroutine/engine/trampoline.h | |
parent | 59e19371de37995fcb36beb16cd6ec030af960bc (diff) | |
download | ydb-9123176b341b6f2658cff5132482b8237c1416c8.tar.gz |
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 2 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 5ece7873b0..37b61cf015 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*); +typedef void (*TContFunc)(TCont*, void*); + +namespace NCoro { -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; + ) noexcept; + + TArrayRef<char> Stack() noexcept; - TArrayRef<char> Stack() noexcept; + TExceptionSafeContext* Context() noexcept { + return &Ctx_; + } - TExceptionSafeContext* Context() noexcept { - return &Ctx_; - } - - void SwitchTo(TExceptionSafeContext* ctx) noexcept { + 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_; }; } |