相关疑难解决方法(0)

取消的 boost::asio 处理程序的处理程序什么时候开始运行?

boost 文档取消的异步连接、发送和接收立即完成,取消操作的处理程序将传递 boost::asio::error::operation_aborted 错误。

我想知道取消的处理程序是否其他(未取消的和新安排的)完成处理程序运行之前运行(并查看 operation_aborted 错误)。

这是我关心的时间表:

acceptHandler 和 readHandler 运行在同一个事件循环和同一个线程上。

  • 时间 t0 - readHandler 在 oldConnectionSocket 上运行
  • 时间 t1 - acceptHandler 运行
  • 时间 t2 - acceptHandler 调用 oldConnectionSocket.cancel
  • 时间 t3 - acceptHandler 关闭 oldConnectionSocket
  • 时间 t4 - acceptHandler 调用 newConnectionSocket.async_read(...readHandler...)
  • 时间 t5 - readHandler 被调用(从哪个上下文?)

是否可以在 t5 时在 newConnectionSocket 上下文中调用 readHandler,然后在 oldConnectionSocket 上下文中使用 operation_aborted 错误调用它?

boost boost-asio

3
推荐指数
1
解决办法
841
查看次数

标签 统计

boost ×1

boost-asio ×1