Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the deal with boost.asio and file 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.

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.

I'm curious if

  1. boost.asio has any kind of file support
  2. boost.asio file support is mature enough for everyday file i/o
  3. Will file support ever be added? Whats the outlook for this?
like image 243
Doug T. Avatar asked Dec 18 '08 17:12

Doug T.


People also ask

What is Boost ASIO?

Boost. Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach. Overview. An overview of the features included in Boost. Asio, plus rationale and design information.

What is an IO service?

An IOService object is the base class the system uses to represent all devices and device-related interfaces. When the user plugs in a device, the system creates one or more service objects to manage interactions with that device.


1 Answers

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.

User Lazin also mentions boost::asio::windows::random_access_handle that can be used for async operations (e.g. named pipes, but also files).

Is boost.asio file support mature enough for everyday file i/o?

As Boost.Asio in itself is widely used by now, and the implementation uses overlapped IO internally, I would say yes.

Will file support ever be added? Whats the outlook for this?

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! :-)

like image 93
vividos Avatar answered Sep 19 '22 21:09

vividos