RESTinio
|
A helper class used in an implementation of run_async function. More...
#include <http_server_run.hpp>
Public Member Functions | |
void | stop () noexcept |
void | wait () noexcept |
Wait for the shutdown of HTTP-server. More... | |
Private Member Functions | |
running_server_instance_t (io_context_holder_t io_context, server_settings_t< typename Http_Server::traits_t > &&settings, std::size_t thread_pool_size) | |
Initializing constructor. More... | |
void | start () |
Start the HTTP-server. More... | |
Private Attributes | |
Http_Server | m_server |
Actual server instance. More... | |
on_pool_runner_t< Http_Server > | m_runner |
The runner of the server. More... | |
Friends | |
template<typename Traits > | |
running_server_handle_t< Traits > | run_async (io_context_holder_t, server_settings_t< Traits > &&, std::size_t thread_pool_size) |
Creates an instance of HTTP-server and launches it on a separate thread or thread pool. More... | |
A helper class used in an implementation of run_async function.
An instance of that class holds an HTTP-server and thread pool on that this HTTP-server is launched.
The HTTP-server will automatically be stopped in the destructor. However, a user can stop the HTTP-server manually by using stop() and wait() methods.
Definition at line 941 of file http_server_run.hpp.
|
inlineprivate |
Initializing constructor.
Definition at line 957 of file http_server_run.hpp.
|
inlineprivate |
Start the HTTP-server.
Returns when HTTP-server started or some startup failure detected. It means that the caller thread will be blocked until HTTP-server calls on_ok or on_error callback.
Throws an exception on an error.
Definition at line 975 of file http_server_run.hpp.
|
inlinenoexcept |
Stop the HTTP-server.
This method initiates shutdown procedure that can take some time. But stop() returns without the waiting for the completeness of the shutdown. To wait for the completeness use wait() method:
Definition at line 1009 of file http_server_run.hpp.
|
inlinenoexcept |
Wait for the shutdown of HTTP-server.
Definition at line 1032 of file http_server_run.hpp.
|
friend |
Creates an instance of HTTP-server and launches it on a separate thread or thread pool.
Usage example:
Or, if user-defined traits should be used:
run_async() returns control when HTTP-server is started or some startup failure is detected. But if a failure is detected then an exception is thrown. So if run_async() returns successfuly then HTTP-server is working.
The started HTTP-server will be automatically stopped at the destruction of the returned value. Because of that the returned value should be stored for the time while HTTP-server is needed.
The started HTTP-server can be stopped manually by calling stop() and wait() methods:
Definition at line 1112 of file http_server_run.hpp.
|
private |
The runner of the server.
Definition at line 954 of file http_server_run.hpp.
|
private |
Actual server instance.
Definition at line 951 of file http_server_run.hpp.