5 #ifndef SRC_IO_TCP_MESSAGE_WRITE_H_
6 #define SRC_IO_TCP_MESSAGE_WRITE_H_
9 #include <boost/asio.hpp>
10 #include <boost/bind/bind.hpp>
11 #include <boost/asio/buffer.hpp>
12 #include <boost/intrusive_ptr.hpp>
13 #include <boost/system/error_code.hpp>
16 using namespace boost::placeholders;
22 static const int kDefaultBufferSize = 4 * 1024;
23 static const int kDefaultWriteBufferSize = 32 * 1024;
24 static const int kMaxPendingBufferSize = 256 * 1024;
25 static const int kMinPendingBufferSize = 64 * 1024;
31 int Send(
const uint8_t *msg,
size_t len,
32 boost::system::error_code *ec);
34 int AsyncSend(
const uint8_t *msg,
size_t len,
35 boost::system::error_code *ec);
39 return (buffer_queue_.size() != 0);
44 BufferQueue::const_iterator it = buffer_queue_.begin();
45 for (; it != buffer_queue_.end(); ++it) {
46 boost::asio::mutable_buffer buffer = *it;
47 total += buffer_size(buffer);
56 void BufferAppend(
const uint8_t *data,
int len);
59 bool UpdateBufferQueue(
size_t wrote,
bool *send_ready);
60 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)