【发布时间】:2020-05-02 08:05:02
【问题描述】:
我正在使用带有 c++ 的 boost asio 库。我发现 io_service 和 io_context 有相似之处。例如两者都有方法运行和其他。有人可以详细说明这两个类之间的区别(如用法、概念、结构差异等)
【问题讨论】:
标签: c++ boost boost-asio
我正在使用带有 c++ 的 boost asio 库。我发现 io_service 和 io_context 有相似之处。例如两者都有方法运行和其他。有人可以详细说明这两个类之间的区别(如用法、概念、结构差异等)
【问题讨论】:
标签: c++ boost boost-asio
你应该使用io_context,它取代了io_service。
根据提升问题#110:
io_service已弃用。是的,您应该使用io_context。请注意,“旧”API 也已被弃用(例如io_service.post(),您应该使用post(io_context, handler))。。 . .
io_service->io_contextio_service.post()->io_context.get_executor().post()io_service.dispatch()->io_context.get_executor().dispatch()
io_service::strand->strand<io_context::executor_type>组合操作自定义挂钩也发生了变化 - 现在只有 2 个 -
boost::asio::associated_allocator和boost::asio::associated_executor,默认寻找get_allocator(), get_executor(),T::allocator_type,T::executor_type组合操作函数对象的成员。这不是一个完整的列表。
这些更改与Networking TS compatibility 有关。
好像已经在Boost 1.66中添加了。
【讨论】:
1.71 他们仍在使用io_service:boost.org/doc/libs/1_71_0/doc/html/boost_process/tutorial.html