add log for study server threading

This commit is contained in:
Chunting Gu
2021-06-11 16:54:28 +08:00
parent d65ca13b7d
commit 74854c4861
4 changed files with 79 additions and 27 deletions
+16 -8
View File
@@ -13,6 +13,11 @@
#include "webcc/request_parser.h"
#include "webcc/response.h"
// Set 1 to enable the log for the study of server thread model.
// Need to use multiple workers and loops for Server::Run().
// Suggest to configure the log level to USER.
#define WEBCC_STUDY_SERVER_THREADING 0
namespace webcc {
class Connection;
@@ -27,11 +32,11 @@ public:
Queue<ConnectionPtr>* queue, ViewMatcher&& view_matcher,
std::size_t buffer_size);
~Connection() = default;
Connection(const Connection&) = delete;
Connection& operator=(const Connection&) = delete;
~Connection() = default;
RequestPtr request() const {
return request_;
}
@@ -53,16 +58,19 @@ public:
void SendResponse(Status status, bool no_keep_alive = false);
private:
void DoRead();
void AsyncRead();
void OnRead(boost::system::error_code ec, std::size_t length);
void DoWrite();
void AsyncWrite();
void OnWriteHeaders(boost::system::error_code ec, std::size_t length);
void DoWriteBody();
void OnWriteBody(boost::system::error_code ec, std::size_t length);
void OnWriteOK();
void OnWriteError(boost::system::error_code ec);
void AsyncWriteBody();
void OnWriteBody(boost::system::error_code ec, std::size_t length);
void HandleWriteOK();
void HandleWriteError(boost::system::error_code ec);
private:
// The socket for the connection.
boost::asio::ip::tcp::socket socket_;