From f794916be64511efa10711339406647b17e37b42 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sat, 17 Feb 2018 13:00:21 +0100 Subject: [PATCH] Enhance `QPromise::wait` documentation --- .gitignore | 1 + docs/qtpromise/qpromise/wait.md | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c360d95..8281286 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +_book dist node_modules *.gcno diff --git a/docs/qtpromise/qpromise/wait.md b/docs/qtpromise/qpromise/wait.md index e8795d0..f2307ac 100644 --- a/docs/qtpromise/qpromise/wait.md +++ b/docs/qtpromise/qpromise/wait.md @@ -4,18 +4,20 @@ QPromise::wait() -> QPromise ``` -This method holds the execution of the remaining code **without** blocking the event loop of the current thread: +This method holds the execution of the remaining code until the `input` promise is resolved (either fulfilled or rejected), **without** blocking the event loop of the current thread: ```cpp int result = -1; -QPromise input = qPromise(QtConcurrent::run([]() { return 42; })); -auto output = input.then([&](int res) { + +QPromise input = qPromise(QtConcurrent::run([]() { + return 42; +})).tap([&](int res) { result = res; }); -// output.isPending() is true && result is -1 +// input.isPending() is true && result is -1 -output.wait(); +input.wait(); -// output.isPending() is false && result is 42 +// input.isPending() is false && result is 42 ```