diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-04-17 18:49:47 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-04-17 18:49:47 +0300 |
commit | 68531f6882c2533c3537acb445adb5c81fabf62b (patch) | |
tree | f25a7901e11d3943846f4b17b5c2ad1e982712bb | |
parent | 01b4e6cd2305374e1316a0bcac01b3119abeeb78 (diff) | |
download | ydb-68531f6882c2533c3537acb445adb5c81fabf62b.tar.gz |
improve code navigation for flags usage
-rw-r--r-- | library/cpp/actors/core/actor.h | 38 | ||||
-rw-r--r-- | library/cpp/actors/core/event.h | 13 |
2 files changed, 27 insertions, 24 deletions
diff --git a/library/cpp/actors/core/actor.h b/library/cpp/actors/core/actor.h index 6f160ac4e8..d12266b0c5 100644 --- a/library/cpp/actors/core/actor.h +++ b/library/cpp/actors/core/actor.h @@ -129,7 +129,7 @@ namespace NActors { struct TActorContext: public TActivationContext { const TActorId SelfID; - + using TEventFlags = IEventHandle::TEventFlags; explicit TActorContext(TMailboxHeader& mailbox, TExecutorThread& executorThread, NHPTimer::STime eventStart, const TActorId& selfID) : TActivationContext(mailbox, executorThread, eventStart) , SelfID(selfID) @@ -137,13 +137,13 @@ namespace NActors { } template <ESendingType SendingType = ESendingType::Common> - bool Send(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; + bool Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; template <ESendingType SendingType = ESendingType::Common> - bool Send(const TActorId& recipient, THolder<IEventBase> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { + bool Send(const TActorId& recipient, THolder<IEventBase> ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { return Send<SendingType>(recipient, ev.Release(), flags, cookie, std::move(traceId)); } template <ESendingType SendingType = ESendingType::Common> - bool Send(const TActorId& recipient, std::unique_ptr<IEventBase> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { + bool Send(const TActorId& recipient, std::unique_ptr<IEventBase> ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { return Send<SendingType>(recipient, ev.release(), flags, cookie, std::move(traceId)); } template <ESendingType SendingType = ESendingType::Common> @@ -206,6 +206,7 @@ namespace NActors { }; struct TActorIdentity: public TActorId { + using TEventFlags = IEventHandle::TEventFlags; explicit TActorIdentity(TActorId actorId) : TActorId(actorId) { @@ -216,8 +217,8 @@ namespace NActors { } template <ESendingType SendingType = ESendingType::Common> - 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; + bool Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; + bool SendWithContinuousExecution(const TActorId& recipient, IEventBase* ev, TEventFlags 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; @@ -228,7 +229,7 @@ namespace NActors { class IActorOps : TNonCopyable { 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 Send(const TActorId& recipient, IEventBase*, IEventHandle::TEventFlags 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. @@ -323,6 +324,7 @@ namespace NActors { protected: TActorCallbackBehaviour CImpl; public: + using TEventFlags = IEventHandle::TEventFlags; using TReceiveFunc = TActorCallbackBehaviour::TReceiveFunc; /// @sa services.proto NKikimrServices::TActivity::EType enum EActorActivity { @@ -375,7 +377,7 @@ namespace NActors { template <class TEventBase> class TEventSenderFromActor: ::TNonCopyable { private: - ui32 Flags = 0; + TEventFlags Flags = 0; ui64 Cookie = 0; const TActorIdentity SenderId; NWilson::TTraceId TraceId = {}; @@ -388,7 +390,7 @@ namespace NActors { } - TEventSenderFromActor& SetFlags(const ui32 flags) { + TEventSenderFromActor& SetFlags(const TEventFlags flags) { Flags = flags; return *this; } @@ -522,11 +524,11 @@ namespace NActors { void Describe(IOutputStream&) const noexcept override; bool Send(TAutoPtr<IEventHandle> ev) const noexcept; - 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{ + bool Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const noexcept final; + bool Send(const TActorId& recipient, THolder<IEventBase> ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const{ return Send(recipient, ev.Release(), flags, cookie, std::move(traceId)); } - bool Send(const TActorId& recipient, std::unique_ptr<IEventBase> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { + bool Send(const TActorId& recipient, std::unique_ptr<IEventBase> ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { return Send(recipient, ev.release(), flags, cookie, std::move(traceId)); } @@ -536,13 +538,13 @@ namespace NActors { } template <ESendingType SendingType> - bool Send(const TActorId& recipient, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; + bool Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const; template <ESendingType SendingType> - bool Send(const TActorId& recipient, THolder<IEventBase> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { + bool Send(const TActorId& recipient, THolder<IEventBase> ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { return Send(recipient, ev.Release(), flags, cookie, std::move(traceId)); } template <ESendingType SendingType> - bool Send(const TActorId& recipient, std::unique_ptr<IEventBase> ev, ui32 flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { + bool Send(const TActorId& recipient, std::unique_ptr<IEventBase> ev, TEventFlags flags = 0, ui64 cookie = 0, NWilson::TTraceId traceId = {}) const { return Send(recipient, ev.release(), flags, cookie, std::move(traceId)); } @@ -833,7 +835,7 @@ namespace NActors { } template <ESendingType SendingType> - bool TActorContext::Send(const TActorId& recipient, IEventBase* ev, ui32 flags, ui64 cookie, NWilson::TTraceId traceId) const { + bool TActorContext::Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags, ui64 cookie, NWilson::TTraceId traceId) const { return Send<SendingType>(new IEventHandle(recipient, SelfID, ev, flags, cookie, nullptr, std::move(traceId))); } @@ -863,12 +865,12 @@ namespace NActors { } template <ESendingType SendingType> - bool TActorIdentity::Send(const TActorId& recipient, IEventBase* ev, ui32 flags, ui64 cookie, NWilson::TTraceId traceId) const { + bool TActorIdentity::Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags, ui64 cookie, NWilson::TTraceId traceId) const { return TActivationContext::Send<SendingType>(new IEventHandle(recipient, *this, ev, flags, cookie, nullptr, std::move(traceId))); } template <ESendingType SendingType> - bool IActor::Send(const TActorId& recipient, IEventBase* ev, ui32 flags, ui64 cookie, NWilson::TTraceId traceId) const { + bool IActor::Send(const TActorId& recipient, IEventBase* ev, TEventFlags flags, ui64 cookie, NWilson::TTraceId traceId) const { return SelfActorId.Send<SendingType>(recipient, ev, flags, cookie, std::move(traceId)); } diff --git a/library/cpp/actors/core/event.h b/library/cpp/actors/core/event.h index 5c2cc726ef..67ab519945 100644 --- a/library/cpp/actors/core/event.h +++ b/library/cpp/actors/core/event.h @@ -97,7 +97,7 @@ namespace NActors { return x; } - enum EFlags { + enum EFlags: ui32 { FlagTrackDelivery = 1 << 0, FlagForwardOnNondelivery = 1 << 1, FlagSubscribeOnSession = 1 << 2, @@ -105,9 +105,10 @@ namespace NActors { FlagGenerateUnsureUndelivered = 1 << 4, FlagExtendedFormat = 1 << 5, }; + using TEventFlags = ui32; const ui32 Type; - const ui32 Flags; + const TEventFlags Flags; const TActorId Recipient; TActorId Sender; const ui64 Cookie; @@ -137,7 +138,7 @@ namespace NActors { return Flags & FlagUseSubChannel ? Sender.LocalId() : 0ULL; } - static ui32 MakeFlags(ui32 channel, ui32 flags) { + static ui32 MakeFlags(ui32 channel, TEventFlags flags) { Y_VERIFY(channel < (1 << ChannelBits)); Y_VERIFY(flags < (1 << ChannelShift)); return (flags | (channel << ChannelShift)); @@ -175,7 +176,7 @@ namespace NActors { return OnNondeliveryHolder.Get() ? OnNondeliveryHolder->Recipient : TActorId(); } - IEventHandle(const TActorId& recipient, const TActorId& sender, IEventBase* ev, ui32 flags = 0, ui64 cookie = 0, + IEventHandle(const TActorId& recipient, const TActorId& sender, IEventBase* ev, TEventFlags flags = 0, ui64 cookie = 0, const TActorId* forwardOnNondelivery = nullptr, NWilson::TTraceId traceId = {}) : Type(ev->Type()) , Flags(flags) @@ -195,7 +196,7 @@ namespace NActors { } IEventHandle(ui32 type, - ui32 flags, + TEventFlags flags, const TActorId& recipient, const TActorId& sender, TIntrusivePtr<TEventSerializedData> buffer, @@ -222,7 +223,7 @@ namespace NActors { // Special ctor for events from interconnect. IEventHandle(const TActorId& session, ui32 type, - ui32 flags, + TEventFlags flags, const TActorId& recipient, const TActorId& sender, TIntrusivePtr<TEventSerializedData> buffer, |