16 #include <event2/event.h>
107 static void LogCallback(
int a_Severity,
const char * a_Msg);
113 static void SignalizeStartup(evutil_socket_t a_Socket,
short a_Events,
void * a_Self);
std::shared_ptr< cTCPLink > cTCPLinkPtr
std::vector< cTCPLinkPtr > cTCPLinkPtrs
std::shared_ptr< cServerHandle > cServerHandlePtr
std::vector< cServerHandlePtr > cServerHandlePtrs
std::shared_ptr< cTCPLink > cTCPLinkPtr
std::vector< cTCPLinkPtr > cTCPLinkPtrs
std::shared_ptr< cServerHandle > cServerHandlePtr
std::vector< cServerHandlePtr > cServerHandlePtrs
Interface that provides the methods available on a single TCP connection.
Interface that provides the methods available on a listening server socket.
std::atomic< bool > m_HasTerminated
Set to true if Terminate has been called.
void Terminate(void)
Terminates all network-related threads.
static void SignalizeStartup(evutil_socket_t a_Socket, short a_Events, void *a_Self)
Callback called by LibEvent when the event loop is started.
std::thread m_EventLoopThread
The thread in which the main LibEvent loop runs.
static cNetworkSingleton & Get(void)
Returns the singleton instance of this class.
void Initialise(void)
Initialises all network-related threads.
event_base * m_EventBase
The main LibEvent container for driving the event loop.
cNetworkLookup & GetLookupThread()
Returns the thread used to perform hostname and IP lookups.
cServerHandlePtrs m_Servers
Container for all servers that are currently active.
void AddLink(const cTCPLinkPtr &a_Link)
Adds the specified link to m_Connections.
cEvent m_StartupEvent
Event that is signalled once the startup is finished and the LibEvent loop is running.
void AddServer(const cServerHandlePtr &a_Server)
Adds the specified link to m_Servers.
cCriticalSection m_CS
Mutex protecting all containers against multithreaded access.
static void RunEventLoop(cNetworkSingleton *a_Self)
Implements the thread that runs LibEvent's event dispatcher loop.
void RemoveLink(const cTCPLink *a_Link)
Removes the specified link from m_Connections.
cNetworkLookup m_LookupThread
The thread on which hostname and ip address lookup is performed.
void RemoveServer(const cServerHandle *a_Server)
Removes the specified server from m_Servers.
static void LogCallback(int a_Severity, const char *a_Msg)
Converts LibEvent-generated log events into log messages in MCS log.
event_base * GetEventBase(void)
Returns the main LibEvent handle for event registering.
~cNetworkSingleton() noexcept(false)
cTCPLinkPtrs m_Connections
Container for all client connections, including ones with pending-connect.