HttpConnection: write_next_noflush for writes without flushing to socket

GitOrigin-RevId: 0b4ffbd7600b1ce466caf8a33897b555a2855211
This commit is contained in:
Arseny Smirnov 2020-07-13 11:55:43 +03:00
parent 15c387eff0
commit fee05df2cc
3 changed files with 10 additions and 2 deletions

View File

@ -34,6 +34,10 @@ class HttpEchoConnection : public Actor {
Scheduler::subscribe(fd_.get_poll_info().extract_pollable_fd(this));
reader_.init(&fd_.input_buffer(), 1024 * 1024, 0);
}
void tear_down() override {
Scheduler::unsubscribe_before_close(fd_.get_poll_info().get_pollable_fd_ref());
fd_.close();
}
void handle_query() {
query_ = HttpQuery();
@ -80,7 +84,7 @@ class HttpEchoConnection : public Actor {
}
};
const int N = 4;
const int N = 8;
class Server : public TcpListener::Callback {
public:
void start_up() override {

View File

@ -55,9 +55,12 @@ void HttpConnectionBase::tear_down() {
fd_.close();
}
void HttpConnectionBase::write_next(BufferSlice buffer) {
void HttpConnectionBase::write_next_noflush(BufferSlice buffer) {
CHECK(state_ == State::Write);
write_buffer_.append(std::move(buffer));
}
void HttpConnectionBase::write_next(BufferSlice buffer) {
write_next_noflush(std::move(buffer));
loop();
}

View File

@ -24,6 +24,7 @@ namespace detail {
class HttpConnectionBase : public Actor {
public:
void write_next_noflush(BufferSlice buffer);
void write_next(BufferSlice buffer);
void write_ok();
void write_error(Status error);