Replies: 1 comment 2 replies
-
Hey @geiseri ! Actually, you should do your logic inside this callback instead. Actually i think you should do something like this instead rpp::source::from_iterable<rpp::memory_model::use_shared>(series)
...
.map(asio::as_future) // change value to future
.subscribe([](future<...> v){ v.get();}); If you still need to extract value and it is really what you want, you have to convert observable to blocking_observable to guarantee completion of observable till exit from subscribe call. Then you could do something like std::future<std::vector<std::string>> job1{};
rpp::source::from_iterable<rpp::memory_model::use_shared>(series)
...
.map(asio::as_future)
.as_blocking()
.subscribe([&job1](std::future<std::vector<std::string>> v) { job1=v;});
std::vector<std::string> result = job1.get(); actually i have plans to extend blocking observable with kind of |
Beta Was this translation helpful? Give feedback.
-
I am not sure you can adequately answer this since I am not sure about your familiarity with boost::asio.
This is an evolution of #323 in that I would use the
rpp::operators::subscribe(...)
to create an async operation based on thecompletion handler. So extending the example:
auto job1 = rpp::source::from_iterable<rpp::memory_model::use_shared>(series) ... .subscribe(asio::as_future); std::vector<std::string> result = job1.get();
With the asio completion handlers you can have different adapters. In the above case it would be a
std::future<std::vector<std::string>>
that would defer execution untilget()
is called.I am not sure this makes sense so far, but I think the core question is what magic is needed to pass to subscribe that would allow me to get the
std::future<>
back?Beta Was this translation helpful? Give feedback.
All reactions