From efb0745efce46698592984d9ac282da4fea30789 Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Tue, 19 Nov 2024 16:33:57 +0100 Subject: [PATCH] enh(SocketReactor): Introduce protected accessors to private members to be used in derived classes. --- Net/include/Poco/Net/SocketReactor.h | 87 +++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/Net/include/Poco/Net/SocketReactor.h b/Net/include/Poco/Net/SocketReactor.h index 653a59a4e..cd14d9615 100644 --- a/Net/include/Poco/Net/SocketReactor.h +++ b/Net/include/Poco/Net/SocketReactor.h @@ -229,6 +229,12 @@ public: /// Returns true if socket is registered with this rector. protected: + using NotifierPtr = Poco::AutoPtr; + using NotificationPtr = Poco::AutoPtr; + using EventHandlerMap = std::map; + using MutexType = Poco::FastMutex; + using ScopedLock = MutexType::ScopedLock; + virtual void onTimeout(); /// Called if the timeout expires and no other events are available. /// @@ -256,14 +262,21 @@ protected: void dispatch(SocketNotification* pNotification); /// Dispatches the given notification to all observers. -private: - typedef Poco::AutoPtr NotifierPtr; - typedef Poco::AutoPtr NotificationPtr; - typedef std::map EventHandlerMap; - typedef Poco::FastMutex MutexType; - typedef MutexType::ScopedLock ScopedLock; - bool hasSocketHandlers(); + + const Params& getParams() const; + int getThreadAffinity() const; + const std::atomic& mustStop() const; + const EventHandlerMap& getHandlers() const; + const PollSet& getPollSet() const; + Notification* getReadableNotification(); + Notification* getWritableNotification(); + Notification* getErrorNotification(); + Notification* getTimeoutNotification(); + Notification* getShutdownNotification(); + +private: + void dispatch(NotifierPtr& pNotifier, SocketNotification* pNotification); NotifierPtr getNotifier(const Socket& socket, bool makeNew = false); @@ -334,6 +347,66 @@ inline void SocketReactor::dispatch(NotifierPtr& pNotifier, SocketNotification* } +inline const SocketReactor::Params& SocketReactor::getParams() const +{ + return _params; +} + + +inline int SocketReactor::getThreadAffinity() const +{ + return _threadAffinity; +} + + +inline const std::atomic& SocketReactor::mustStop() const +{ + return _stop; +} + + +inline const SocketReactor::EventHandlerMap& SocketReactor::getHandlers() const +{ + return _handlers; +} + + +inline const PollSet& SocketReactor::getPollSet() const +{ + return _pollSet; +} + + +inline Notification* SocketReactor::getReadableNotification() +{ + return _pReadableNotification; +} + + +inline Notification* SocketReactor::getWritableNotification() +{ + return _pWritableNotification; +} + + +inline Notification* SocketReactor::getErrorNotification() +{ + return _pErrorNotification; +} + + +inline Notification* SocketReactor::getTimeoutNotification() +{ + return _pTimeoutNotification; +} + + +inline Notification* SocketReactor::getShutdownNotification() +{ + return _pShutdownNotification; +} + + } } // namespace Poco::Net