I am using boost.future<T>
with continuations, in boost 1.56.
I have an API that returns a future, that I want to use from inside a
continuation. So in theory, I need to .unwrap
the future before chaining the
second continuation.
So I do the following:
auto result = api_returns_future().then([](boost::future<R> && result) {
do_something_with_result();
//Note I could call .get() here, but I don't
return api_returns_future();
}).unwrap() //Now I unwrap the future here
.then([](boost::future<R> && result) { ... });
Namely, I have:
future<R>::then
- In the first continuation, I return from the lambda with an API call that returns a
boost::future<R>
and later I unwrap it. - After that I want to attach another continuation, but this continuation is never called.
Question:
- It would be correct to do this in the first continuation:
return api_returns_future().get()
(note I call.get()
from inside the continuation directly` and give up on unwrapping?. Has this alternative some drawback for the asynchroncity of my code?
EDIT: I updated the question to better reflect what I want to ask after some more research.
Thanks