aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/impl.cpp
diff options
context:
space:
mode:
authornocomer <nocomer@yandex-team.com>2022-10-14 15:48:41 +0300
committernocomer <nocomer@yandex-team.com>2022-10-14 15:48:41 +0300
commit71316eadc4b07f0334a6b87e4b9133a3ce81810b (patch)
tree0a4ae9189c2ec04544f8addfa574a2de83808ff8 /library/cpp/coroutine/engine/impl.cpp
parent11cf1c4aa90b19d0a23b3a645ade2d53e4cadb53 (diff)
downloadydb-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.cpp7
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.