TrinityCore
NetworkThread< SocketType > Class Template Reference

#include <NetworkThread.h>

Public Member Functions

 NetworkThread ()
 
virtual ~NetworkThread ()
 
void Stop ()
 
bool Start ()
 
void Wait ()
 
int32 GetConnectionCount () const
 
void AddSocket (std::shared_ptr< SocketType > sock)
 
boost::asio::ip::tcp::socket * GetSocketForAccept ()
 

Protected Member Functions

virtual void SocketAdded (std::shared_ptr< SocketType >)
 
virtual void SocketRemoved (std::shared_ptr< SocketType >)
 
void AddNewSockets ()
 
void Run ()
 
void Update ()
 

Private Types

typedef std::vector< std::shared_ptr< SocketType > > SocketContainer
 

Private Attributes

std::atomic< int32_connections
 
std::atomic< bool > _stopped
 
std::thread * _thread
 
SocketContainer _sockets
 
std::mutex _newSocketsLock
 
SocketContainer _newSockets
 
Trinity::Asio::IoContext _ioContext
 
boost::asio::ip::tcp::socket _acceptSocket
 
Trinity::Asio::DeadlineTimer _updateTimer
 

Detailed Description

template<class SocketType>
class NetworkThread< SocketType >

Definition at line 33 of file NetworkThread.h.

Member Typedef Documentation

◆ SocketContainer

template<class SocketType >
typedef std::vector<std::shared_ptr<SocketType> > NetworkThread< SocketType >::SocketContainer
private

Definition at line 157 of file NetworkThread.h.

Constructor & Destructor Documentation

◆ NetworkThread()

template<class SocketType >
NetworkThread< SocketType >::NetworkThread ( )
inline

Definition at line 36 of file NetworkThread.h.

◆ ~NetworkThread()

template<class SocketType >
virtual NetworkThread< SocketType >::~NetworkThread ( )
inlinevirtual

Definition at line 41 of file NetworkThread.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddNewSockets()

template<class SocketType >
void NetworkThread< SocketType >::AddNewSockets ( )
inlineprotected

Definition at line 95 of file NetworkThread.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddSocket()

template<class SocketType >
void NetworkThread< SocketType >::AddSocket ( std::shared_ptr< SocketType >  sock)
inline

Definition at line 80 of file NetworkThread.h.

+ Here is the call graph for this function:

◆ GetConnectionCount()

template<class SocketType >
int32 NetworkThread< SocketType >::GetConnectionCount ( ) const
inline

Definition at line 75 of file NetworkThread.h.

◆ GetSocketForAccept()

template<class SocketType >
boost::asio::ip::tcp::socket * NetworkThread< SocketType >::GetSocketForAccept ( )
inline

Definition at line 89 of file NetworkThread.h.

◆ Run()

template<class SocketType >
void NetworkThread< SocketType >::Run ( )
inlineprotected

Definition at line 116 of file NetworkThread.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SocketAdded()

template<class SocketType >
virtual void NetworkThread< SocketType >::SocketAdded ( std::shared_ptr< SocketType >  )
inlineprotectedvirtual

Reimplemented in WorldSocketThread.

Definition at line 92 of file NetworkThread.h.

+ Here is the caller graph for this function:

◆ SocketRemoved()

template<class SocketType >
virtual void NetworkThread< SocketType >::SocketRemoved ( std::shared_ptr< SocketType >  )
inlineprotectedvirtual

Reimplemented in Trinity::Net::Http::HttpService< SessionImpl >::Thread, and WorldSocketThread.

Definition at line 93 of file NetworkThread.h.

+ Here is the caller graph for this function:

◆ Start()

template<class SocketType >
bool NetworkThread< SocketType >::Start ( )
inline

Definition at line 57 of file NetworkThread.h.

+ Here is the call graph for this function:

◆ Stop()

template<class SocketType >
void NetworkThread< SocketType >::Stop ( )
inline

Definition at line 51 of file NetworkThread.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Update()

template<class SocketType >
void NetworkThread< SocketType >::Update ( )
inlineprotected

Definition at line 129 of file NetworkThread.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Wait()

template<class SocketType >
void NetworkThread< SocketType >::Wait ( )
inline

Definition at line 66 of file NetworkThread.h.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _acceptSocket

template<class SocketType >
boost::asio::ip::tcp::socket NetworkThread< SocketType >::_acceptSocket
private

Definition at line 170 of file NetworkThread.h.

◆ _connections

template<class SocketType >
std::atomic<int32> NetworkThread< SocketType >::_connections
private

Definition at line 159 of file NetworkThread.h.

◆ _ioContext

template<class SocketType >
Trinity::Asio::IoContext NetworkThread< SocketType >::_ioContext
private

Definition at line 169 of file NetworkThread.h.

◆ _newSockets

template<class SocketType >
SocketContainer NetworkThread< SocketType >::_newSockets
private

Definition at line 167 of file NetworkThread.h.

◆ _newSocketsLock

template<class SocketType >
std::mutex NetworkThread< SocketType >::_newSocketsLock
private

Definition at line 166 of file NetworkThread.h.

◆ _sockets

template<class SocketType >
SocketContainer NetworkThread< SocketType >::_sockets
private

Definition at line 164 of file NetworkThread.h.

◆ _stopped

template<class SocketType >
std::atomic<bool> NetworkThread< SocketType >::_stopped
private

Definition at line 160 of file NetworkThread.h.

◆ _thread

template<class SocketType >
std::thread* NetworkThread< SocketType >::_thread
private

Definition at line 162 of file NetworkThread.h.

◆ _updateTimer

template<class SocketType >
Trinity::Asio::DeadlineTimer NetworkThread< SocketType >::_updateTimer
private

Definition at line 171 of file NetworkThread.h.


The documentation for this class was generated from the following file: