cgv
cgv::os::web_server_thread Class Referenceabstract

web server interface that runs in its own thread More...

#include <web_server.h>

Inheritance diagram for cgv::os::web_server_thread:
cgv::os::thread cgv::os::web_server

Public Member Functions

 web_server_thread (unsigned int _port=8080)
 create a web server that listens to the given port
 
 ~web_server_thread ()
 calls the stop method of the web_server
 
void start ()
 start the web server in a separate thread More...
 
void run ()
 reimplements the run method that simply starts the web server
 
void start (bool _delete_after_termination=false)
 start the implemented run() method (asynchronly) and destruct the thread object More...
 
void stop ()
 
void kill ()
 kill a running thread
 
void wait_for_completion ()
 join the current thread More...
 
bool is_running ()
 return true if thread is running
 
bool have_stop_request ()
 check if there is a stop request
 
thread_id_type get_id () const
 return id of this thread
 
virtual void handle_request (http_request &request)=0
 reimplement to handle requests
 
void stop ()
 can only be called from a different thread
 
unsigned int get_port () const
 return the port to which the web server listens
 

Static Public Member Functions

static void wait_for_signal (condition_mutex &cm)
 sleep till the signal from the given condition_mutex is sent, lock the mutex first and unlock after waiting More...
 
static void wait_for_signal_with_lock (condition_mutex &cm)
 prefered approach to wait for signal and implemented as { cm.lock(); wait_for_signal(cm); cm.unlock(); }
 
static bool wait_for_signal_or_timeout (condition_mutex &cm, unsigned millisec)
 sleep till the signal from the given condition_mutex is sent or the timeout is reached, lock the mutex first and unlock after waiting
 
static bool wait_for_signal_or_timeout_with_lock (condition_mutex &cm, unsigned millisec)
 prefered approach to wait for signal or the timeout is reached and implemented as { cm.lock(); wait_for_signal_or_timeout(cm,millisec); cm.unlock(); }
 
static void wait (unsigned millisec)
 wait the given number of milliseconds
 
static thread_id_type get_current_thread_id ()
 return the id of the currently executed thread
 

Protected Member Functions

void execute ()
 executes the run method
 

Detailed Description

web server interface that runs in its own thread

Member Function Documentation

◆ start() [1/2]

void cgv::os::web_server_thread::start ( )

start the web server in a separate thread

start the html server in a separate thread

◆ start() [2/2]

void cgv::os::thread::start ( bool  _delete_after_termination = false)
inherited

start the implemented run() method (asynchronly) and destruct the thread object

start the implemented run() method (asynchronly)

◆ stop()

void cgv::os::thread::stop ( )
inherited

try to stop the thread execution via indicating a stop request. The existence of a stop request can be recognized by the no_stop_request() method. This test should be done periodically within the implementation of the run() method, e.g. to leave the execution loop in a clean way.

◆ wait_for_completion()

void cgv::os::thread::wait_for_completion ( )
inherited

join the current thread

the thread is interpreted as a slave thread and started from another master thread. This method is called from the master thread in order to wait for termination of the slave thread.

◆ wait_for_signal()

void cgv::os::thread::wait_for_signal ( condition_mutex cm)
staticinherited

sleep till the signal from the given condition_mutex is sent, lock the mutex first and unlock after waiting

sleep till the signal from the given condition_mutex is sent


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