title: Need help on asynchrous non-blocking file loading with boost::asio and boost::iostreams ( or something different? )
body: <p>I'm coding in c++, and I'm trying to load an image file asynchronously. After some research, I found some mentions about using boost::asio and boost::iostreams to do it. However, the documentation and example for boost::asio is mostly socket related, so it doesn't help me much.</p>
  
  <p>Here is what I need:</p>
  
  <ul>
  <li>Load a file asynchronously and upon load completion, executes a callback function.(In my case, the callback function executes a javascript function object using v8 javascript engine)</li>
  <li>The callback function must be executed within the same thread as the main function. ( Because v8 is not thread safe.)</li>
  <li>Need to work on linux and windows. (separate implementations are ok)</li>
  </ul>
  
  <p>So, something like this would be really nice:</p>
  
  <pre><code>async_read("test.jpg", &amp;the_callback_function);
  </code></pre>
  
  <p>The function should not block, and upon file load completion, it should run 'the_callback_function'.</p>
  
  <p>Edit: as joshperry pointed out, boost::asio might not be able to dispatch back to the main thread. So, I guess I don't have to limit to only boost::asio and boost:iostreams. Any c/c++ library that can help with this requirement should be fine. Thanks!</p>