What#39;s the deal with boost.asio and file i/o?(boost.asio 和文件 i/o 有什么关系?)
问题描述
我注意到 boost.asio 有很多涉及套接字、串行端口和各种非文件示例的示例.对于我来说,Google 并没有真正提到 asio 是否是执行异步文件 i/o 的好方法或有效方法.
I've noticed that boost.asio has a lot of examples involving sockets, serial ports, and all sorts of non-file examples. Google hasn't really turned up a lot for me that mentions if asio is a good or valid approach for doing asynchronous file i/o.
我有大量数据想要异步写入磁盘.这可以通过 Windows(我的平台)中的原生重叠 io 来完成,但我更喜欢有一个独立于平台的解决方案.
I've got gobs of data i'd like to write to disk asynchronously. This can be done with native overlapped io in Windows (my platform), but I'd prefer to have a platform independent solution.
我很好奇
- boost.asio 有任何类型的文件支持
- boost.asio 文件支持对于日常文件输入/输出已经足够成熟
- 是否会添加文件支持?前景如何?
推荐答案
boost.asio 是否有任何类型的文件支持?
从(我认为)Boost 1.36(包含 Asio 1.2.0)开始,您可以使用 [boost::asio::]windows::stream_handle 或 windows::random_access_handle 来包装 HANDLE 并执行异步读写方法内部使用 OVERLAPPED 结构.
Has boost.asio any kind of file support?
Starting with (I think) Boost 1.36 (which contains Asio 1.2.0) you can use [boost::asio::]windows::stream_handle or windows::random_access_handle to wrap a HANDLE and perform asynchronous read and write methods on it that use the OVERLAPPED structure internally.
用户 Lazin 还提到 boost::asio::windows::random_access_handle 可用于异步操作(例如命名管道,也包括文件).
User Lazin also mentions boost::asio::windows::random_access_handle that can be used for async operations (e.g. named pipes, but also files).
由于 Boost.Asio 本身现在被广泛使用,并且实现内部使用了重叠 IO,我会说是的.
As Boost.Asio in itself is widely used by now, and the implementation uses overlapped IO internally, I would say yes.
由于在 Asio 网站上没有找到路线图,我想说不会有新的添加到Boost.Asio 用于此功能.尽管贡献者总是有机会向 Boost.Asio 添加代码和类.也许你甚至可以自己贡献缺失的部分!:-)
As there's no roadmap found on the Asio website, I would say that there will be no new additions to Boost.Asio for this feature. Although there's always the chance of contributors adding code and classes to Boost.Asio. Maybe you can even contribute the missing parts yourself! :-)
这篇关于boost.asio 和文件 i/o 有什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:boost.asio 和文件 i/o 有什么关系?


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01