http_server.hpp
Go to the documentation of this file.
1 #ifndef CPP_WEB_SERVER_HTTP_SERVER_HPP
2 #define CPP_WEB_SERVER_HTTP_SERVER_HPP
3 
6 
7 #include <boost/asio.hpp>
8 #include <boost/function.hpp>
9 #include <boost/noncopyable.hpp>
10 #include <boost/shared_ptr.hpp>
11 #include <boost/thread/thread.hpp>
12 
13 #include <string>
14 #include <vector>
15 
16 namespace async_web_server_cpp
17 {
18 
26 class HttpServer : private boost::noncopyable
27 {
28 public:
29  HttpServer(const std::string& address, const std::string& port,
30  HttpServerRequestHandler request_handler,
31  std::size_t thread_pool_size);
32  ~HttpServer();
33 
34  void run();
35 
36  void stop();
37 
38 private:
39  void start_accept();
40 
41  void handle_accept(const boost::system::error_code& e);
42 
43  boost::asio::io_service io_service_;
44  boost::asio::ip::tcp::acceptor acceptor_;
45  std::size_t thread_pool_size_;
46  std::vector<boost::shared_ptr<boost::thread>> threads_;
47  boost::shared_ptr<HttpConnection> new_connection_;
49 };
50 
51 } // namespace async_web_server_cpp
52 
53 #endif
async_web_server_cpp::HttpServer::~HttpServer
~HttpServer()
Definition: http_server.cpp:25
async_web_server_cpp::HttpServer::start_accept
void start_accept()
Definition: http_server.cpp:41
async_web_server_cpp::HttpServer::HttpServer
HttpServer(const std::string &address, const std::string &port, HttpServerRequestHandler request_handler, std::size_t thread_pool_size)
Definition: http_server.cpp:8
http_request_handler.hpp
async_web_server_cpp::HttpServer::request_handler_
HttpServerRequestHandler request_handler_
Definition: http_server.hpp:48
http_connection.hpp
async_web_server_cpp::HttpServerRequestHandler
boost::function< bool(const HttpRequest &, boost::shared_ptr< HttpConnection >, const char *begin, const char *end)> HttpServerRequestHandler
Definition: http_request_handler.hpp:12
async_web_server_cpp::HttpServer
Definition: http_server.hpp:26
async_web_server_cpp::HttpServer::thread_pool_size_
std::size_t thread_pool_size_
Definition: http_server.hpp:45
async_web_server_cpp::HttpServer::acceptor_
boost::asio::ip::tcp::acceptor acceptor_
Definition: http_server.hpp:44
async_web_server_cpp
Definition: http_connection.hpp:14
async_web_server_cpp::HttpServer::threads_
std::vector< boost::shared_ptr< boost::thread > > threads_
Definition: http_server.hpp:46
async_web_server_cpp::HttpServer::handle_accept
void handle_accept(const boost::system::error_code &e)
Definition: http_server.cpp:49
async_web_server_cpp::HttpServer::new_connection_
boost::shared_ptr< HttpConnection > new_connection_
Definition: http_server.hpp:47
async_web_server_cpp::HttpServer::io_service_
boost::asio::io_service io_service_
Definition: http_server.hpp:43
async_web_server_cpp::HttpServer::run
void run()
Definition: http_server.cpp:30
async_web_server_cpp::HttpServer::stop
void stop()
Definition: http_server.cpp:58


async_web_server_cpp
Author(s): Mitchell Wills , Russel Toris
autogenerated on Tue Mar 1 2022 23:49:06