diff options
author | va-kuznecov <va-kuznecov@ydb.tech> | 2022-12-22 11:47:40 +0300 |
---|---|---|
committer | va-kuznecov <va-kuznecov@ydb.tech> | 2022-12-22 11:47:40 +0300 |
commit | ed846a1194eb88e712a28e36b2f6fbbfbe801d17 (patch) | |
tree | c21504c40d18cd1ec1d271237907df3a830c68d0 | |
parent | 5e473ae99515dcc385d93e469a3b5bcce2a316e6 (diff) | |
download | ydb-ed846a1194eb88e712a28e36b2f6fbbfbe801d17.tar.gz |
Add additional SendWithContinuousExecution
-rw-r--r-- | library/cpp/actors/core/actor.cpp | 12 | ||||
-rw-r--r-- | library/cpp/actors/core/actor.h | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/library/cpp/actors/core/actor.cpp b/library/cpp/actors/core/actor.cpp index e86539ce10..e20c82529a 100644 --- a/library/cpp/actors/core/actor.cpp +++ b/library/cpp/actors/core/actor.cpp @@ -15,6 +15,10 @@ namespace NActors { return ExecutorThread.Send(ev); } + bool TActorContext::SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, ui32 flags, ui64 cookie, NWilson::TTraceId traceId) const { + return SendWithContinuousExecution(new IEventHandle(recipient, SelfID, ev, flags, cookie, nullptr, std::move(traceId))); + } + bool TActorContext::SendWithContinuousExecution(TAutoPtr<IEventHandle> ev) const { if (TlsThreadContext) { return ExecutorThread.SendWithContinuousExecution(ev); @@ -37,6 +41,10 @@ namespace NActors { return SelfActorId.Send(recipient, ev, flags, cookie, std::move(traceId)); } + bool IActor::SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, ui32 flags, ui64 cookie, NWilson::TTraceId traceId) const noexcept { + return SelfActorId.SendWithContinuousExecution(recipient, ev, flags, cookie, std::move(traceId)); + } + bool TActivationContext::Send(TAutoPtr<IEventHandle> ev) { return TlsActivationContext->ExecutorThread.Send(ev); } @@ -61,6 +69,10 @@ namespace NActors { return TActivationContext::Send(new IEventHandle(recipient, *this, ev, flags, cookie, nullptr, std::move(traceId))); } + bool TActorIdentity::SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, ui32 flags, ui64 cookie, NWilson::TTraceId traceId) const { + return TActivationContext::SendWithContinuousExecution(new IEventHandle(recipient, *this, ev, flags, cookie, nullptr, std::move(traceId))); + } + void TActorIdentity::Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie) const { return TActivationContext::Schedule(deadline, new IEventHandle(*this, {}, ev), cookie); } diff --git a/library/cpp/actors/core/actor.h b/library/cpp/actors/core/actor.h index bd90344b37..bc42b37147 100644 --- a/library/cpp/actors/core/actor.h +++ b/library/cpp/actors/core/actor.h @@ -117,6 +117,11 @@ namespace NActors { } bool Send(TAutoPtr<IEventHandle> ev) const; bool SendWithContinuousExecution(TAutoPtr<IEventHandle> ev) const; + bool SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; + template <typename TEvent> + bool SendWithContinuousExecution(const TActorId& recipient, THolder<TEvent> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { + return SendWithContinuousExecution(recipient, static_cast<IEventBase*>(ev.Release()), flags, cookie, std::move(traceId)); + } TInstant Now() const; TMonotonic Monotonic() const; @@ -178,6 +183,7 @@ namespace NActors { } bool Send(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; + bool SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const; void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const; void Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const; @@ -189,6 +195,7 @@ namespace NActors { public: virtual void Describe(IOutputStream&) const noexcept = 0; virtual bool Send(const TActorId& recipient, IEventBase*, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const noexcept = 0; + virtual bool SendWithContinuousExecution(const TActorId& recipient, IEventBase*, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const noexcept = 0; /** * Schedule one-shot event that will be send at given time point in the future. @@ -470,6 +477,17 @@ namespace NActors { return Send(recipient, MakeHolder<TEvent>(std::forward<TEventArgs>(args)...)); } + bool SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const noexcept final; + template <typename TEvent> + bool SendWithContinuousExecution(const TActorId& recipient, THolder<TEvent> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const{ + return SendWithContinuousExecution(recipient, static_cast<IEventBase*>(ev.Release()), flags, cookie, std::move(traceId)); + } + + template <class TEvent, class ... TEventArgs> + bool SendWithContinuousExecution(TActorId recipient, TEventArgs&& ... args) const { + return SendWithContinuousExecution(recipient, MakeHolder<TEvent>(std::forward<TEventArgs>(args)...)); + } + void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final; void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final; void Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final; |