Boost asio io_service vs io_context(增强ASIO io_服务与io_Context)
本文介绍了增强ASIO io_服务与io_Context的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有C++的Boost ASIO库。我发现io_service和io_context有相似之处。例如,两者都有方法运行和其他。谁能详细介绍一下这两个类别之间的区别(如用法、概念、结构差异等)
推荐答案
您应该使用io_context
,它取代了io_service
。
根据Boost问题#110:
io_service
已弃用。是的,您应该使用io_context
。请注意,";old";API也已弃用(例如io_service.post()
,您应该使用post(io_context, handler)
)。。。。
io_service
-&>io_context
io_service.post()
-&>io_context.get_executor().post()
io_service.dispatch()
-&>io_context.get_executor().dispatch()
还对组合操作定制挂钩进行了更改- 现在只有2个-
io_service::strand
-&>strand<io_context::executor_type>
boost::asio::associated_allocator
和boost::asio::associated_executor
,默认情况下查找get_allocator()
,get_executor()
,T::allocator_type
,T::executor_type
合成的操作函数对象的成员。这不是完整的列表。
这些更改与Networking TS compatibility相关。
似乎已添加到Boost 1.66中。
这篇关于增强ASIO io_服务与io_Context的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:增强ASIO io_服务与io_Context


猜你喜欢
- 哪个更快:if (bool) 或 if(int)? 2022-01-01
- 将函数的返回值分配给引用 C++? 2022-01-01
- GDB 不显示函数名 2022-01-01
- 使用 __stdcall & 调用 DLLVS2013 中的 GetProcAddress() 2021-01-01
- XML Schema 到 C++ 类 2022-01-01
- 从父 CMakeLists.txt 覆盖 CMake 中的默认选项(...)值 2021-01-01
- 如何提取 __VA_ARGS__? 2022-01-01
- DoEvents 等效于 C++? 2021-01-01
- 将 hdc 内容复制到位图 2022-09-04
- OpenGL 对象的 RAII 包装器 2021-01-01