asio::async_write and strand

前端 未结 2 1950
感情败类
感情败类 2020-12-10 00:05
asio::async_write(m_socket, asio::buffer(buf, bytes),
                custom_alloc(m_strand.wrap(custom_alloc(_OnSend))));

Does this code guarantee

2条回答
  •  被撕碎了的回忆
    2020-12-10 00:37

    UPD: This answer is wrong=) For anyone interested you can check details in the tail of comments, thanks to Tanner Sansbury.


    No. This guarantees your completion handler will be called with strand lock. This not includes calls to async_write_some.

    Also boost::asio does not have something like "write queue" and you need to manage async_write calls in order to prevent writing mixed content.

提交回复
热议问题