diff options
author | nocomer <nocomer@yandex-team.com> | 2022-12-07 17:37:14 +0300 |
---|---|---|
committer | nocomer <nocomer@yandex-team.com> | 2022-12-07 17:37:14 +0300 |
commit | 073cfa733cd8ec817135f28cb8a2719452094d73 (patch) | |
tree | 5be69eaa31ee3bb9ed540c8aaca8177941597847 /library/cpp/coroutine/engine/impl.h | |
parent | 37030c245fe253ac59f915e72acb74d5e677cca0 (diff) | |
download | ydb-073cfa733cd8ec817135f28cb8a2719452094d73.tar.gz |
Improve error handling: add counters for internal, other and because of ban errors/fails, provide source of errors and reasons of coroutine cancellations
Diffstat (limited to 'library/cpp/coroutine/engine/impl.h')
-rw-r--r-- | library/cpp/coroutine/engine/impl.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/library/cpp/coroutine/engine/impl.h b/library/cpp/coroutine/engine/impl.h index ca523cdaf3..ec4af17fcf 100644 --- a/library/cpp/coroutine/engine/impl.h +++ b/library/cpp/coroutine/engine/impl.h @@ -30,6 +30,12 @@ namespace NCoro::NStack { } class TCont : private TIntrusiveListItem<TCont> { + friend class TContExecutor; + friend class TIntrusiveListItem<TCont>; + friend class NCoro::TEventWaitQueue; + friend class NCoro::TTrampoline; + +public: struct TJoinWait: public TIntrusiveListItem<TJoinWait> { TJoinWait(TCont& c) noexcept; @@ -39,11 +45,6 @@ class TCont : private TIntrusiveListItem<TCont> { TCont& Cont_; }; - friend class TContExecutor; - friend class TIntrusiveListItem<TCont>; - friend class NCoro::TEventWaitQueue; - friend class NCoro::TTrampoline; - private: TCont( NCoro::NStack::IAllocator& allocator, @@ -99,7 +100,9 @@ public: /// \param this корутина, которая будет ждать /// \param c корутина, которую будем ждать /// \param deadLine максимальное время ожидания - bool Join(TCont* c, TInstant deadLine = TInstant::Max()) noexcept; + /// \param forceStop кастомный обработчик ситуации, когда завершается время ожидания или отменяется ожидающая корутина (this) + /// дефолтное поведение - отменить ожидаемую корутину (c->Cancel()) + bool Join(TCont* c, TInstant deadLine = TInstant::Max(), std::function<void(TJoinWait&, TCont*)> forceStop = {}) noexcept; void ReSchedule() noexcept; @@ -113,6 +116,10 @@ public: return std::move(Exception_); } + void SetException(THolder<std::exception> exception) noexcept { + Exception_ = std::move(exception); + } + private: void Terminate(); |