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
boost::shared_ptr< HttpConnection > new_connection_
Definition: http_server.hpp:47
boost::asio::io_service io_service_
Definition: http_server.hpp:43
boost::asio::ip::tcp::acceptor acceptor_
Definition: http_server.hpp:44
void handle_accept(const boost::system::error_code &e)
Definition: http_server.cpp:49
boost::function< bool(const HttpRequest &, boost::shared_ptr< HttpConnection >, const char *begin, const char *end)> HttpServerRequestHandler
std::vector< boost::shared_ptr< boost::thread > > threads_
Definition: http_server.hpp:46
HttpServer(const std::string &address, const std::string &port, HttpServerRequestHandler request_handler, std::size_t thread_pool_size)
Definition: http_server.cpp:8
HttpServerRequestHandler request_handler_
Definition: http_server.hpp:48


async_web_server_cpp
Author(s): Mitchell Wills , Russel Toris
autogenerated on Mon Feb 28 2022 21:54:08