jeudi 22 janvier 2015

Mutliple continuation chaining: boost.future unwrapping. How to do it

I am using boost.future<T> with continuations, in boost 1.56.


I cannot figure out how to do the following:



auto result = api_returns_future().then([](boost::future<R> && result) {
do_something_with_result();
return api_returns_future();
}).then([](boost::future<R> && result) { ... });


Namely, I have:



  1. future<R>::then

  2. In the first continuation, I return from the lambda with an API call that returns a boost::future<R>. In theory, I would need to unwrap it, but I don't see such an API call available.

  3. After that I want to attach another continuation.


Questions:



  1. Do I need something like unwrap? How is it possible that it is not available?

  2. Will automatic unwrapping be performed, in case 1. is not needed?

  3. It would be correct to do this in the first continuation: return api_returns_future().get(). Or it has some drawback?


Thanks


Aucun commentaire:

Enregistrer un commentaire