0

I am decoding an image file: the file has tagged header info mixed with 4K pixel code blocks.

Platform is primarily windows, but could be osx or linux.

Once I read in a code block, I can launch (asynchronously) my decode routine on this block, while continuing to read the file for header info and code blocks.

Currently, I do synchronous reads using fread(...).

Is is worthwhile to switch to boost asio to asynchronously read in the code blocks? The read callback could trigger my decode routine. But I wouldn't have to wait for the read before I carry on to the next code block.

If so, can anyone point me to a reference/tutorial covering boost::asio asynch reads from disk?

Jacko
  • 12,665
  • 18
  • 75
  • 126

1 Answers1

0

There is nothing specific to asio in order to read from disk, you can continue to use your code with fread, at the end of reading you post two new "jobs", one for decoding the previous read, another one for reading next block. If you want to do "real" multithreading you need a pool of two "io.run()" threads . Or you can create a pool of x threads, while splitting the read or your entire file in x sections.

Anyway asio is powerfull and very easy to use, but requires a learning curve, may be documentation is missing a tutorial. IMHO that post is a very good introduction to understand the way to use asio, You should read, and read again ...

Community
  • 1
  • 1
Jean Davy
  • 2,062
  • 1
  • 19
  • 24