ADTF  3.18.2
AbstractThreadedServerabstract
Inheritance diagram for AbstractThreadedServer:
[legend]

Public Member Functions

 AbstractThreadedServer (size_t threads)
 
virtual bool StartListening ()
 This method should signal the Connector to start waiting for requests, in any way that is appropriate for the derived connector class. More...
 
virtual bool StopListening ()
 This method should signal the Connector to stop waiting for requests, in any way that is appropriate for the derived connector class. More...
 
- Public Member Functions inherited from AbstractServerConnector
void ProcessRequest (const std::string &request, std::string &response)
 
void SetHandler (IClientConnectionHandler *handler)
 
IClientConnectionHandlerGetHandler ()
 

Protected Member Functions

virtual bool InitializeListener ()=0
 InitializeListener should initialize sockets, file descriptors etc. More...
 
virtual int CheckForConnection ()=0
 CheckForConnection should poll for a new connection. More...
 
virtual void HandleConnection (int connection)=0
 HandleConnection must handle connection information for a given handle that has been returned by CheckForConnection() More...
 

Private Member Functions

void ListenLoop ()
 

Private Attributes

bool running
 
std::unique_ptr< std::thread > listenerThread
 
ThreadPool threadPool
 
size_t threads
 

Detailed Description

Definition at line 10 of file abstractthreadedserver.h.

Member Function Documentation

◆ CheckForConnection()

virtual int CheckForConnection ( )
protectedpure virtual

CheckForConnection should poll for a new connection.

This must be a non-blocking call.

Returns
a handle which is passed on to HandleConnection()

◆ HandleConnection()

virtual void HandleConnection ( int  connection)
protectedpure virtual

HandleConnection must handle connection information for a given handle that has been returned by CheckForConnection()

Parameters
connection

◆ InitializeListener()

virtual bool InitializeListener ( )
protectedpure virtual

InitializeListener should initialize sockets, file descriptors etc.

Returns

◆ StartListening()

virtual bool StartListening ( )
virtual

This method should signal the Connector to start waiting for requests, in any way that is appropriate for the derived connector class.

If something went wrong, this method should return false, otherwise true.

Implements AbstractServerConnector.

◆ StopListening()

virtual bool StopListening ( )
virtual

This method should signal the Connector to stop waiting for requests, in any way that is appropriate for the derived connector class.

If something went wrong, this method should return false, otherwise true.

Implements AbstractServerConnector.