3 #include "../messages/message.hh"
9 #include <boost/asio.hpp>
10 #include <boost/asio/spawn.hpp>
11 #include <boost/asio/error.hpp>
18 using boost::asio::ip::tcp;
34 void do_write(std::shared_ptr<std::string>&);
46 void commit(std::shared_ptr<std::string>&);
49 void on_write(
const boost::system::error_code&,
size_t);
52 void read_coroutine(boost::asio::yield_context);
56 std::queue<std::shared_ptr<std::string>> messages_queue;
57 std::atomic<bool> is_writing;
58 boost::asio::io_service& iosvc;
60 std::mutex queue_mutex;
AsyncChannel(NetObserver *node_)
Definition: asyncchannel.cc:26
Definition: netobserver.hh:9
tcp::socket & get_socket()
Get internal socket.
Definition: asyncchannel.cc:38
Definition: message.hh:15
void do_write(messages::Message *) override
Write asynchronously the message.
Definition: asyncchannel.cc:53
void commit(std::shared_ptr< std::string > &)
Add a message to the sending queue.
Definition: asyncchannel.cc:73
void do_write_buffer()
Write asynchronously the message sharing the payload.
Definition: asyncchannel.cc:66
void do_read()
This method implements the reading loop.
Definition: asyncchannel.cc:157
Definition: channel.hh:10
virtual ~AsyncChannel()
Definition: asyncchannel.cc:33
Represent an opened channel between two endpoints.
Definition: asyncchannel.hh:24