On Mittwoch, 30. November 2016 21:47:34 CET Christophe Henry wrote:
After having a deeper dive into the documentation and examples, one pattern I see popping up quite frequently is this: future<R> fut = my_promise.get_future(); post_callback(some_work, [this](expected<R> r) { this->my_promise.set_value(r.get()); }); return fut;
This is simply to make examples easier to run (it finishes the example). It demonstrates that the only one which blocks in an application built on Asynchronous is main(). This might be more confusing than useful and I probably should get rid of this.
Understood. It's always a difficult task to present clear and good examples and best practices. Out of curiosity (I can't recall reading that in the documentation, correct me if I am wrong), how is a real and complex application supposed to signal shutdown/completion? The answer to this question is somehow important. You make it very clear, in the documentation and here in this thread, that having a chain of future.then (which conceptually really are just callbacks that are called whenever the future became ready), is not the way to go because eventually you need to block the thread of execution. At least as your very last call main, for example. Joining the threads of your active threadpools also blocks the thread of execution. So where is the difference? Which technique did I miss?