3

I would like to read a large file in C++ in an asynchronous manner. I already use boost::asio to perform async reads from network sockets, and I wonder if it is possible to extend boost::asio to do non-blocking reads on regular files.

I could use a separate thread to do the job, but is there a more native solution, that would fit well with asio::io_service ?

I am using Linux, but I won't reject a portable solution with std::ifstream ;)

Steakfly
  • 357
  • 3
  • 11

1 Answers1

-1

Linux does not support non-blocking file reads. boost::asio does not support async read files on linux, too.

You can use aio_read(3) manually, but it creates a system thread to do the job.

Galimov Albert
  • 7,269
  • 1
  • 24
  • 50