mirror of
https://github.com/simonbrunel/qtpromise.git
synced 2025-07-08 02:08:13 +08:00
- Add npm package.json to make easier maintaining dependencies. - Make markdown files consistent using remark. - Wrap markdown lines to 100 characters. - Better README.md layout and visual. - Enable VuePress landing/home page. - Upgrade to latest VuePress version. - Add link to the new Qt Marketplace.
31 lines
550 B
Markdown
31 lines
550 B
Markdown
---
|
|
title: .wait
|
|
---
|
|
|
|
# QPromise::wait
|
|
|
|
*Since: 0.1.0*
|
|
|
|
```cpp
|
|
QPromise<T>::wait() -> QPromise<T>
|
|
```
|
|
|
|
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<int> input = QtPromise::resolve(QtConcurrent::run([]() {
|
|
return 42;
|
|
})).tap([&](int res) {
|
|
result = res;
|
|
});
|
|
|
|
// input.isPending() is true && result is -1
|
|
|
|
input.wait();
|
|
|
|
// input.isPending() is false && result is 42
|
|
```
|