#pragma once #include "acceptor_status.h" #include "defs.h" #include "event_loop.h" #include "netaddr.h" #include "session_impl.h" #include "shutdown_state.h" #include #include namespace NBus { namespace NPrivate { class TAcceptor : public NEventLoop::IEventHandler, private ::NActor::TActor { friend struct TBusSessionImpl; friend class ::NActor::TActor; public: TAcceptor(TBusSessionImpl* session, ui64 acceptorId, SOCKET socket, const TNetAddr& addr); void HandleEvent(SOCKET socket, void* cookie) override; void Shutdown(); inline ::NActor::TActor* GetActor() { return this; } private: void SendStatus(TInstant now); void Act(::NActor::TDefaultTag); private: const ui64 AcceptorId; TBusSessionImpl* const Session; NEventLoop::TChannelPtr Channel; TAcceptorStatus Stats; TAtomicShutdownState ShutdownState; struct TGranStatus { TGranStatus(TDuration gran) : Listen(gran) { } TGranUp Listen; }; TGranStatus GranStatus; }; } }