TrinityCore
Loading...
Searching...
No Matches
Trinity::Net::NetworkThread< SocketType > Class Template Reference

#include <NetworkThread.h>

Public Member Functions

 NetworkThread ()
 
 NetworkThread (NetworkThread const &)=delete
 
 NetworkThread (NetworkThread &&)=delete
 
NetworkThreadoperator= (NetworkThread const &)=delete
 
NetworkThreadoperator= (NetworkThread &&)=delete
 
virtual ~NetworkThread ()
 
void Stop ()
 
bool Start ()
 
void Wait ()
 
int32 GetConnectionCount () const
 
virtual void AddSocket (std::shared_ptr< SocketType > sock)
 
Trinity::Net::IoContextTcpSocketGetSocketForAccept ()
 

Protected Member Functions

virtual void SocketAdded (std::shared_ptr< SocketType > const &)
 
virtual void SocketRemoved (std::shared_ptr< SocketType > const &)
 
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::unique_ptr< std::thread > _thread
 
SocketContainer _sockets
 
std::mutex _newSocketsLock
 
SocketContainer _newSockets
 
Trinity::Asio::IoContext _ioContext
 
Trinity::Net::IoContextTcpSocket _acceptSocket
 
Trinity::Asio::DeadlineTimer _updateTimer
 

Detailed Description

template<class SocketType>
class Trinity::Net::NetworkThread< SocketType >

Definition at line 40 of file NetworkThread.h.

Member Typedef Documentation

◆ SocketContainer

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

Definition at line 164 of file NetworkThread.h.

Constructor & Destructor Documentation

◆ NetworkThread() [1/3]

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

Definition at line 43 of file NetworkThread.h.

◆ NetworkThread() [2/3]

template<class SocketType >
Trinity::Net::NetworkThread< SocketType >::NetworkThread ( NetworkThread< SocketType > const &  )
delete

◆ NetworkThread() [3/3]

template<class SocketType >
Trinity::Net::NetworkThread< SocketType >::NetworkThread ( NetworkThread< SocketType > &&  )
delete

◆ ~NetworkThread()

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

Definition at line 53 of file NetworkThread.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddNewSockets()

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

Definition at line 102 of file NetworkThread.h.

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

◆ AddSocket()

template<class SocketType >
virtual void Trinity::Net::NetworkThread< SocketType >::AddSocket ( std::shared_ptr< SocketType >  sock)
inlinevirtual

Definition at line 88 of file NetworkThread.h.

+ Here is the call graph for this function:

◆ GetConnectionCount()

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

Definition at line 83 of file NetworkThread.h.

◆ GetSocketForAccept()

template<class SocketType >
Trinity::Net::IoContextTcpSocket * Trinity::Net::NetworkThread< SocketType >::GetSocketForAccept ( )
inline

Definition at line 96 of file NetworkThread.h.

◆ operator=() [1/2]

template<class SocketType >
NetworkThread & Trinity::Net::NetworkThread< SocketType >::operator= ( NetworkThread< SocketType > &&  )
delete

◆ operator=() [2/2]

template<class SocketType >
NetworkThread & Trinity::Net::NetworkThread< SocketType >::operator= ( NetworkThread< SocketType > const &  )
delete

◆ Run()

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

Definition at line 123 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 Trinity::Net::NetworkThread< SocketType >::SocketAdded ( std::shared_ptr< SocketType > const &  )
inlineprotectedvirtual

Reimplemented in WorldSocketThread.

Definition at line 99 of file NetworkThread.h.

+ Here is the caller graph for this function:

◆ SocketRemoved()

template<class SocketType >
virtual void Trinity::Net::NetworkThread< SocketType >::SocketRemoved ( std::shared_ptr< SocketType > const &  )
inlineprotectedvirtual

Reimplemented in WorldSocketThread.

Definition at line 100 of file NetworkThread.h.

+ Here is the caller graph for this function:

◆ Start()

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

Definition at line 66 of file NetworkThread.h.

+ Here is the call graph for this function:

◆ Stop()

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

Definition at line 60 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 Trinity::Net::NetworkThread< SocketType >::Update ( )
inlineprotected

Definition at line 136 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 Trinity::Net::NetworkThread< SocketType >::Wait ( )
inline

Definition at line 75 of file NetworkThread.h.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _acceptSocket

template<class SocketType >
Trinity::Net::IoContextTcpSocket Trinity::Net::NetworkThread< SocketType >::_acceptSocket
private

Definition at line 177 of file NetworkThread.h.

◆ _connections

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

Definition at line 166 of file NetworkThread.h.

◆ _ioContext

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

Definition at line 176 of file NetworkThread.h.

◆ _newSockets

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

Definition at line 174 of file NetworkThread.h.

◆ _newSocketsLock

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

Definition at line 173 of file NetworkThread.h.

◆ _sockets

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

Definition at line 171 of file NetworkThread.h.

◆ _stopped

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

Definition at line 167 of file NetworkThread.h.

◆ _thread

template<class SocketType >
std::unique_ptr<std::thread> Trinity::Net::NetworkThread< SocketType >::_thread
private

Definition at line 169 of file NetworkThread.h.

◆ _updateTimer

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

Definition at line 178 of file NetworkThread.h.


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