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! :-)
相关文章