Where/when is the buffer deleted in boost::asio::async_write(..) for the code provided

  Kiến thức lập trình

The code below works and works well for millions of messages on a daily basis. My question how/where does “msg” that is set up as a const vector get deleted if in fact that is what’s happening? I do not do anything in the completion handler to remove it.
Thanks

The typedef is set in the tcp_connection class. The method is also part of the class.

int tcp_connection::writeToSocketAsync(std::string sMsg)
{
    typedef boost::shared_ptr<CharVec>  CharVecPtr;

    const std::vector<char> msg(sMsg.begin(), sMsg.end());
    
    CharVecPtr tmsg = boost::make_shared<CharVec>(msg);

    boost::asio::async_write(socket_,
        boost::asio::buffer(*tmsg),
        boost::asio::transfer_all(),
        strand_.wrap(boost::bind(&tcp_connection::handle_write,
            this,
            boost::asio::placeholders::error,
            boost::asio::placeholders::bytes_transferred)));
}

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT