TrinityCore
Loading...
Searching...
No Matches
Trinity::Net::NetworkThread< SocketType, DerivedThread > 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
 
void AddSocket (std::shared_ptr< SocketType > &&sock)
 
Trinity::Asio::IoContextGetIoContext ()
 

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::Asio::DeadlineTimer _updateTimer
 

Detailed Description

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

Definition at line 35 of file NetworkThread.h.

Member Typedef Documentation

◆ SocketContainer

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

Definition at line 159 of file NetworkThread.h.

Constructor & Destructor Documentation

◆ NetworkThread() [1/3]

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

Definition at line 38 of file NetworkThread.h.

◆ NetworkThread() [2/3]

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

◆ NetworkThread() [3/3]

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

◆ ~NetworkThread()

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

Definition at line 48 of file NetworkThread.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddNewSockets()

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

Definition at line 97 of file NetworkThread.h.

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

◆ AddSocket()

template<class SocketType , class DerivedThread >
void Trinity::Net::NetworkThread< SocketType, DerivedThread >::AddSocket ( std::shared_ptr< SocketType > &&  sock)
inline

Definition at line 83 of file NetworkThread.h.

+ Here is the call graph for this function:

◆ GetConnectionCount()

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

Definition at line 78 of file NetworkThread.h.

◆ GetIoContext()

template<class SocketType , class DerivedThread >
Trinity::Asio::IoContext * Trinity::Net::NetworkThread< SocketType, DerivedThread >::GetIoContext ( )
inline

Definition at line 91 of file NetworkThread.h.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ Run()

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

Definition at line 118 of file NetworkThread.h.

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

◆ SocketAdded()

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

Reimplemented in WorldSocketThread.

Definition at line 94 of file NetworkThread.h.

+ Here is the caller graph for this function:

◆ SocketRemoved()

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

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

Definition at line 95 of file NetworkThread.h.

+ Here is the caller graph for this function:

◆ Start()

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

Definition at line 61 of file NetworkThread.h.

+ Here is the call graph for this function:

◆ Stop()

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

Definition at line 55 of file NetworkThread.h.

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

◆ Update()

template<class SocketType , class DerivedThread >
void Trinity::Net::NetworkThread< SocketType, DerivedThread >::Update ( )
inlineprotected

Definition at line 131 of file NetworkThread.h.

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

◆ Wait()

template<class SocketType , class DerivedThread >
void Trinity::Net::NetworkThread< SocketType, DerivedThread >::Wait ( )
inline

Definition at line 70 of file NetworkThread.h.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _connections

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

Definition at line 161 of file NetworkThread.h.

◆ _ioContext

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

Definition at line 171 of file NetworkThread.h.

◆ _newSockets

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

Definition at line 169 of file NetworkThread.h.

◆ _newSocketsLock

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

Definition at line 168 of file NetworkThread.h.

◆ _sockets

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

Definition at line 166 of file NetworkThread.h.

◆ _stopped

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

Definition at line 162 of file NetworkThread.h.

◆ _thread

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

Definition at line 164 of file NetworkThread.h.

◆ _updateTimer

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

Definition at line 172 of file NetworkThread.h.


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