diff options
author | nocomer <nocomer@yandex-team.com> | 2022-10-14 15:48:41 +0300 |
---|---|---|
committer | nocomer <nocomer@yandex-team.com> | 2022-10-14 15:48:41 +0300 |
commit | 71316eadc4b07f0334a6b87e4b9133a3ce81810b (patch) | |
tree | 0a4ae9189c2ec04544f8addfa574a2de83808ff8 /library/cpp/coroutine/engine/impl.cpp | |
parent | 11cf1c4aa90b19d0a23b3a645ade2d53e4cadb53 (diff) | |
download | ydb-71316eadc4b07f0334a6b87e4b9133a3ce81810b.tar.gz |
Allow to pass exception to the coroutine to be cancelled
Diffstat (limited to 'library/cpp/coroutine/engine/impl.cpp')
-rw-r--r-- | library/cpp/coroutine/engine/impl.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/cpp/coroutine/engine/impl.cpp b/library/cpp/coroutine/engine/impl.cpp index 7ae6f74051..08f358127d 100644 --- a/library/cpp/coroutine/engine/impl.cpp +++ b/library/cpp/coroutine/engine/impl.cpp @@ -106,6 +106,13 @@ void TCont::Cancel() noexcept { } } +void TCont::Cancel(THolder<std::exception> exception) noexcept { + if (!Cancelled()) { + Exception_ = std::move(exception); + Cancel(); + } +} + void TCont::ReSchedule() noexcept { if (Cancelled()) { // Legacy code may expect a Cancelled coroutine to be scheduled without delay. |