Skip to content

Commit

Permalink
enh(SocketReactor): Introduce protected accessors to private members …
Browse files Browse the repository at this point in the history
…to be used in derived classes.
  • Loading branch information
matejk committed Nov 19, 2024
1 parent 64d8777 commit efb0745
Showing 1 changed file with 79 additions and 6 deletions.
85 changes: 79 additions & 6 deletions Net/include/Poco/Net/SocketReactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ class Net_API SocketReactor: public Poco::Runnable
/// Returns true if socket is registered with this rector.

protected:
using NotifierPtr = Poco::AutoPtr<SocketNotifier>;
using NotificationPtr = Poco::AutoPtr<SocketNotification>;
using EventHandlerMap = std::map<poco_socket_t, NotifierPtr>;
using MutexType = Poco::FastMutex;
using ScopedLock = MutexType::ScopedLock;

virtual void onTimeout();
/// Called if the timeout expires and no other events are available.
///
Expand Down Expand Up @@ -256,14 +262,21 @@ class Net_API SocketReactor: public Poco::Runnable
void dispatch(SocketNotification* pNotification);
/// Dispatches the given notification to all observers.

bool hasSocketHandlers();

const Params& getParams() const;
int getThreadAffinity() const;
const std::atomic<bool>& mustStop() const;
const EventHandlerMap& getHandlers() const;
const PollSet& getPollSet() const;
Notification* getReadableNotification();
Notification* getWritableNotification();
Notification* getErrorNotification();
Notification* getTimeoutNotification();
Notification* getShutdownNotification();

private:
typedef Poco::AutoPtr<SocketNotifier> NotifierPtr;
typedef Poco::AutoPtr<SocketNotification> NotificationPtr;
typedef std::map<poco_socket_t, NotifierPtr> EventHandlerMap;
typedef Poco::FastMutex MutexType;
typedef MutexType::ScopedLock ScopedLock;

bool hasSocketHandlers();
void dispatch(NotifierPtr& pNotifier, SocketNotification* pNotification);
NotifierPtr getNotifier(const Socket& socket, bool makeNew = false);

Expand Down Expand Up @@ -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<bool>& 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


Expand Down

0 comments on commit efb0745

Please sign in to comment.