6 #ifndef SRC_IO_TCP_MESSAGE_WRITE_H_
7 #define SRC_IO_TCP_MESSAGE_WRITE_H_
10 #include <boost/asio.hpp>
11 #include <boost/bind/bind.hpp>
12 #include <boost/asio/buffer.hpp>
13 #include <boost/intrusive_ptr.hpp>
14 #include <boost/system/error_code.hpp>
17 using namespace boost::placeholders;
23 static const int kDefaultBufferSize = 4 * 1024;
24 static const int kDefaultWriteBufferSize = 32 * 1024;
25 static const int kMaxPendingBufferSize = 256 * 1024;
26 static const int kMinPendingBufferSize = 64 * 1024;
32 int Send(
const uint8_t *msg,
size_t len,
33 boost::system::error_code *ec);
35 int AsyncSend(
const uint8_t *msg,
size_t len,
36 boost::system::error_code *ec);
40 return (buffer_queue_.size() != 0);
45 BufferQueue::const_iterator it = buffer_queue_.begin();
46 for (; it != buffer_queue_.end(); ++it) {
47 boost::asio::mutable_buffer buffer = *it;
48 total += buffer_size(buffer);
57 void BufferAppend(
const uint8_t *data,
int len);
60 bool UpdateBufferQueue(
size_t wrote,
bool *send_ready);
61 void TriggerAsyncWrite();
boost::intrusive_ptr< TcpSession > TcpSessionPtr
int Send(const uint8_t *msg, size_t len, boost::system::error_code *ec)
std::list< boost::asio::mutable_buffer > BufferQueue
bool IsWritePending() const
size_t GetBufferQueueSize() const
BufferQueue buffer_queue_
void DeleteBuffer(boost::asio::mutable_buffer buffer)