shanshanpt / seastar_example

seastar example
8 stars 6 forks source link

do_launch_request is not used in client.cc #2

Closed asias closed 5 years ago

asias commented 6 years ago
future<> do_launch_request() {
    net::fragment frag { const_cast<char*>(str_txbuf.c_str()), buf_size };
    net::packet pack(frag, deleter());
    return _out.write(std::move(pack)).then([this] {
        return _out.flush();
    }).then([this] {
        return _in.read_exactly(buf_size).then([this] (auto&& data) {
            _nr_done++;
            if (_echo_client.done(_nr_done)) {
                return make_ready_future<>();
            }
            return this->do_launch_request();
        });
    });
}
shanshanpt commented 6 years ago

@asias Not use the function.

The run() function will execute keep_doing_read and keep_doing_write directly.

            // read
            keep_doing([conn, this] () {
                return conn->_in.read_exactly(buf_size).then([this] (auto&& data) {
                });
            }).then([conn] {
                conn->_out.close();
            });

            // write
            keep_doing([conn, this] () {
                net::fragment frag { const_cast<char*>(str_txbuf.c_str()), buf_size };
                net::packet pack(frag, deleter());
                return conn->_out.write(std::move(pack)).then([this, conn] {
                    conn->_out.flush();
                });
            }).then([conn] {
                conn->_out.close();
            });