title: boost::asio::spawn yield as callback
body: <p>I'm trying to rewrite a project using <code>boost::asio::spawn</code> coroutines. Some parts of the project cannot be changed. For example, the storage protocol library is also written with <code>boost::asio</code>, but without coroutines. </p>
  
  <p>The problem is how to convert <code>yield_context</code> into a normal callback (a <code>boost::function</code> object or a classical functor).</p>
  
  <p>This is what we have in the storage library API:</p>
  
  <pre><code>void async_request_data(uint64_t item_id, boost::function&lt; void(Request_result *) &gt; callback);
  </code></pre>
  
  <p>As we know from examples, the asio yield context can be used like this:</p>
  
  <pre><code>    my_socket.async_read_some(boost::asio::buffer(data), yield);
  </code></pre>
  
  <p>In this case a <code>boost::asio::yield_context</code> object serves as a callback for <strong>async_read_some</strong>. I would like to pass  a <strong>yield</strong> object as the second argument to <code>async_request_data</code>, so i can use it in  a synchronous manner.</p>
  
  <p>How can this be done? I think it may be possible via some proxy-object, possibly using an approach based on <strong>asio_handler_invoke</strong>.  But I am having trouble seeing how to do this. </p>