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 ```