mirror of
https://github.com/simonbrunel/qtpromise.git
synced 2024-11-22 02:34:30 +08:00
Add QPromise<T>::timeout
documentation
This commit is contained in:
parent
4af2740d80
commit
9d2a4ca00f
@ -12,6 +12,7 @@
|
||||
* [.isRejected](qtpromise/qpromise/isrejected.md)
|
||||
* [.tap](qtpromise/qpromise/tap.md)
|
||||
* [.then](qtpromise/qpromise/then.md)
|
||||
* [.timeout](qtpromise/qpromise/timeout.md)
|
||||
* [.wait](qtpromise/qpromise/wait.md)
|
||||
* [::all (static)](qtpromise/qpromise/all.md)
|
||||
* [::reject (static)](qtpromise/qpromise/reject.md)
|
||||
|
@ -11,6 +11,7 @@
|
||||
* [`QPromise<T>::isRejected`](qpromise/isrejected.md)
|
||||
* [`QPromise<T>::tap`](qpromise/tap.md)
|
||||
* [`QPromise<T>::then`](qpromise/then.md)
|
||||
* [`QPromise<T>::timeout`](qpromise/timeout.md)
|
||||
* [`QPromise<T>::wait`](qpromise/wait.md)
|
||||
|
||||
### Public Static Members
|
||||
|
18
docs/qtpromise/qpromise/timeout.md
Normal file
18
docs/qtpromise/qpromise/timeout.md
Normal file
@ -0,0 +1,18 @@
|
||||
## `QPromise<T>::timeout`
|
||||
|
||||
```
|
||||
QPromise<T>::timeout(int msec, any error = QPromiseTimeoutException) -> QPromise<T>
|
||||
```
|
||||
|
||||
This method returns a promise that will be resolved with the `input` promise's fulfillment value or rejection reason. However, if the `input` promise is not fulfilled or rejected within `msec` milliseconds, the `output` promise is rejected with `error` as the reason (`QPromiseTimeoutException` by default).
|
||||
|
||||
```cpp
|
||||
QPromise<int> input = {...}
|
||||
auto output = input.timeout(2000)
|
||||
.then([](int res) {
|
||||
// operation succeeded within 2 seconds
|
||||
})
|
||||
.fail([](const QPromiseTimeoutException& e) {
|
||||
// operation timed out!
|
||||
});
|
||||
```
|
Loading…
Reference in New Issue
Block a user