Boost logo

Boost Users :

Subject: Re: [Boost-users] Is boost asio appropriate for this use case ?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-06-09 16:53:13


On 9 Jun 2014 at 15:21, Aaron Boxer wrote:

> 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.

Almost certainly not. fread() will be fairly close to optimal unless
your images are in the > 100's Mb range. A memory map will be optimal
though, plus on Windows a fread() turns into a memory map under the
bonnet too, so a direct memory map will save a memory copy.

If your images are bigger than that, or you're reading many images
from many files, you definitely want proposed Boost.AFIO not ASIO.

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

For AFIO:

https://ci.nedprod.com/view/Boost.AFIO/job/Boost.AFIO%20Build%20Docume
ntation/Boost.AFIO_Documentation/doc/html/afio/quickstart.html

It's a brutal API, but if you need the performance that's the
sacrifice.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net