summaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/actor.h
diff options
context:
space:
mode:
authorDaniil Cherednik <[email protected]>2023-05-05 11:09:01 +0300
committerDaniil Cherednik <[email protected]>2023-05-05 11:09:01 +0300
commitb5a989b16cafa8a3b3bc076f1097a0eda6f48c06 (patch)
tree4da744117a5aab37758921fa43b95a3068e5aec1 /library/cpp/actors/core/actor.h
parentfc1cffcfa7f0497a1f97b384a24bcbf23362f3be (diff)
Ydb stable 23-1-2623.1.26
x-stable-origin-commit: 22184a7e157553d447f17a2dffc4ea2d32dfd74d
Diffstat (limited to 'library/cpp/actors/core/actor.h')
-rw-r--r--library/cpp/actors/core/actor.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/library/cpp/actors/core/actor.h b/library/cpp/actors/core/actor.h
index 9ed36082230..b67c04b09b3 100644
--- a/library/cpp/actors/core/actor.h
+++ b/library/cpp/actors/core/actor.h
@@ -29,6 +29,7 @@ namespace NActors {
ui32 CapturedActivation = 0;
ESendingType CapturedType = ESendingType::Lazy;
ESendingType SendingType = ESendingType::Common;
+ bool IsEnoughCpu = true;
};
extern Y_POD_THREAD(TThreadContext*) TlsThreadContext;
@@ -436,20 +437,24 @@ namespace NActors {
// must be called to wrap any call trasitions from one actor to another
template<typename TActor, typename TMethod, typename... TArgs>
- static decltype((std::declval<TActor>().*std::declval<TMethod>())(std::declval<TArgs>()...))
- InvokeOtherActor(TActor& actor, TMethod&& method, TArgs&&... args) {
- struct TRecurseContext: TActorContext {
- TActivationContext* Prev;
+ static std::invoke_result_t<TMethod, TActor, TArgs...> InvokeOtherActor(TActor& actor, TMethod&& method, TArgs&&... args) {
+ struct TRecurseContext : TActorContext {
+ TActivationContext* const Prev;
+
TRecurseContext(const TActorId& actorId)
: TActorContext(TActivationContext::ActorContextFor(actorId))
- , Prev(TlsActivationContext) {
+ , Prev(TlsActivationContext)
+ {
TlsActivationContext = this;
}
+
~TRecurseContext() {
+ Y_VERIFY(TlsActivationContext == this, "TlsActivationContext mismatch; probably InvokeOtherActor was invoked from a coroutine");
TlsActivationContext = Prev;
}
} context(actor.SelfId());
- return (actor.*method)(std::forward<TArgs>(args)...);
+
+ return std::invoke(std::forward<TMethod>(method), actor, std::forward<TArgs>(args)...);
}
virtual void Registered(TActorSystem* sys, const TActorId& owner);
@@ -486,6 +491,12 @@ namespace NActors {
}
protected:
+ void SetEnoughCpu(bool isEnough) {
+ if (TlsThreadContext) {
+ TlsThreadContext->IsEnoughCpu = isEnough;
+ }
+ }
+
void Describe(IOutputStream&) const noexcept override;
bool Send(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const noexcept final;
bool Send(const TActorId& recipient, THolder<IEventBase> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const {