aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2023-02-02 15:17:28 +0300
committeralexvru <alexvru@ydb.tech>2023-02-02 15:17:28 +0300
commit526605c8005b6d58f0dedf178129c57fd082811d (patch)
tree004bf1975dca28a8e2a9f4402988fb7cb4bd7c52 /library/cpp
parentea84a5fee092f387e3e16209ce3773a9edad3602 (diff)
downloadydb-526605c8005b6d58f0dedf178129c57fd082811d.tar.gz
Allow using TlsActivationContext inside coroutine
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/actors/core/actor_coroutine.cpp10
-rw-r--r--library/cpp/actors/core/actor_coroutine.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/library/cpp/actors/core/actor_coroutine.cpp b/library/cpp/actors/core/actor_coroutine.cpp
index 0ab4d2b24d..cdd6fdef4c 100644
--- a/library/cpp/actors/core/actor_coroutine.cpp
+++ b/library/cpp/actors/core/actor_coroutine.cpp
@@ -78,7 +78,7 @@ namespace NActors {
const TActorContext& TActorCoroImpl::GetActorContext() const {
Y_VERIFY(ActorContext);
- return *ActorContext;
+ return ActorContext.value();
}
bool TActorCoroImpl::ProcessEvent(THolder<IEventHandle> ev) {
@@ -92,16 +92,16 @@ namespace NActors {
}
// prepare actor context for in-coroutine use
+ Y_VERIFY(!ActorContext);
TActivationContext *ac = TlsActivationContext;
- TlsActivationContext = nullptr;
- TActorContext ctx(ac->Mailbox, ac->ExecutorThread, ac->EventStart, SelfActorId);
- ActorContext = &ctx;
+ ActorContext.emplace(ac->Mailbox, ac->ExecutorThread, ac->EventStart, SelfActorId);
+ TlsActivationContext = &ActorContext.value();
Resume();
// drop actor context
TlsActivationContext = ac;
- ActorContext = nullptr;
+ ActorContext.reset();
return Finished;
}
diff --git a/library/cpp/actors/core/actor_coroutine.h b/library/cpp/actors/core/actor_coroutine.h
index 6f04f70ef8..16651da81d 100644
--- a/library/cpp/actors/core/actor_coroutine.h
+++ b/library/cpp/actors/core/actor_coroutine.h
@@ -21,7 +21,7 @@ namespace NActors {
THolder<IEventHandle> PendingEvent;
bool Finished = false;
ui64 WaitCookie = 0;
- TActorContext *ActorContext = nullptr;
+ std::optional<TActorContext> ActorContext;
protected:
TActorIdentity SelfActorId = TActorIdentity(TActorId());