forb
Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
forb::base_skeleton Class Referenceabstract

The class from which any automatically generated skeleton will inherit. More...

#include <base_skeleton.hpp>

Public Member Functions

 base_skeleton (int port, int queue_size=10)
 Constructs a new skeleton object associated with the given port. More...
 
virtual ~base_skeleton ()=default
 Virtual destructor.
 
 base_skeleton (const base_skeleton &other)=delete
 This class does not support copy construction.
 
base_skeletonoperator= (const base_skeleton &other)=delete
 This class does not support copy assignment.
 
 base_skeleton (base_skeleton &&other) noexcept=default
 This class supports move construction.
 
base_skeletonoperator= (base_skeleton &&other) noexcept=default
 This class supports move assignment.
 
void start_server ()
 The object will spawn a new thread ans start accepting connection requests.
 
void join_server ()
 Joins the server thread, waiting for it to terminate, which happens only in case of an error within the listening thread. More...
 

Protected Member Functions

virtual void execute_call (call_id_t code, forb::streams::stream *callstream, forb::streams::stream *datastream)=0
 Virtual method that implementations shall define to actually serve a request call. More...
 

Static Protected Member Functions

static void listen_thread_body (base_skeleton *impl)
 The body of the server thread, which will block on accept calls and spawn other threads, one for each new request. More...
 
static void call_thread_body (base_skeleton *impl, forb::streams::socket call_socket)
 The body of the threads which will serve each call request. More...
 

Detailed Description

The class from which any automatically generated skeleton will inherit.

Constructor & Destructor Documentation

§ base_skeleton()

forb::base_skeleton::base_skeleton ( int  port,
int  queue_size = 10 
)
inlineexplicit

Constructs a new skeleton object associated with the given port.

The second argument is optional and it's used to change the default queue size for the server socket.

Member Function Documentation

§ call_thread_body()

void forb::base_skeleton::call_thread_body ( forb::base_skeleton impl,
forb::streams::socket  call_socket 
)
staticprotected

The body of the threads which will serve each call request.

One thread will be spawned for each incoming connection and it will be used to serve multiple request calls within the same connection, until the connection is closed.

§ execute_call()

virtual void forb::base_skeleton::execute_call ( call_id_t  code,
forb::streams::stream callstream,
forb::streams::stream datastream 
)
protectedpure virtual

Virtual method that implementations shall define to actually serve a request call.

Skeletons defining this method will be automatically generated by the FORB IDL compiler.

§ join_server()

void forb::base_skeleton::join_server ( )

Joins the server thread, waiting for it to terminate, which happens only in case of an error within the listening thread.

NOTICE: this function is not safe in the sense that some connection threads may still be around when this function terminates.

§ listen_thread_body()

void forb::base_skeleton::listen_thread_body ( forb::base_skeleton impl)
staticprotected

The body of the server thread, which will block on accept calls and spawn other threads, one for each new request.

The first argument is a pointer to the actual implementation of the base_skeleton class.


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