if(!do_send_msg(true)&&!send_buffer.empty())//send msg in sequence
super::send_msg();//just make sure no pending msgs
#endif
do_send_msg(true);//just make sure no pending msgs
}
else
{
...
...
@@ -449,7 +453,7 @@ private:
on_send_error(ec,sending_msgs);
sending_msgs.clear();//clear sending messages after on_send_error, then user can decide how to deal with them in on_send_error
sending=false;
this->clear_sending();
}
}
...
...
@@ -481,15 +485,12 @@ private:
usingsuper::temp_msg_can;
usingsuper::send_buffer;
usingsuper::sending;
#ifdef ASCS_PASSIVE_RECV
usingsuper::reading;
#endif
usingsuper::rw_strand;
//before gcc 5.0, std::list::size() has linear complexity, very embarrassing!
//so use std::vector (member variable) to reduce memory allocation and keep the number of sending msgs (its size() has constant complexity, it's very important).
typenamesuper::in_container_typesending_msgs;
std::vector<asio::const_buffer>sending_buffer;//just to reduce memory allocation and keep the size of sending items (linear complexity, it's very important).