diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2020-10-12 11:30:51 +0200 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2020-10-16 09:48:10 +0200 |
commit | 3ca600bd2d02a6950938789cef96229b15ec0cfa (patch) | |
tree | 1a6b5801efae7294582b12e10b4c2a7f67796d05 /src/corelib/thread/qpromise.qdoc | |
parent | 696d94b132b2f352b5e6b889ad91c2437417fae8 (diff) |
Make QPromise::addResult() return boolean status of operation
Changed QPromise::addResult() to return bool value. True is returned
when result is added and false is returned when e.g. promise is in final
state (canceled or finished) or when addResult() is called twice with
the same index as argument (in which case new value is rejected)
Updated QFutureInterface::reportFinished() that accepts optional result
as argument to align with other result adding methods. This function
is "internal" only (as of now), so no documentation update is needed
Change-Id: I2d63069246e5e5c8cf04529c22bb296faaaae53d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/thread/qpromise.qdoc')
-rw-r--r-- | src/corelib/thread/qpromise.qdoc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/corelib/thread/qpromise.qdoc b/src/corelib/thread/qpromise.qdoc index 4b7b497b3f..279bc8766a 100644 --- a/src/corelib/thread/qpromise.qdoc +++ b/src/corelib/thread/qpromise.qdoc @@ -107,13 +107,17 @@ Returns a future associated with this promise. */ -/*! \fn template <typename T> void QPromise<T>::addResult(const T &result, int index = -1) +/*! \fn template <typename T> bool QPromise<T>::addResult(const T &result, int index = -1) + \fn template <typename T> bool QPromise<T>::addResult(T &&result, int index = -1) Adds \a result to the internal result collection at \a index position. If index is unspecified, \a result is added to the end of the collection. - \note addResult() rejects \a result if there's already another result in the - collection stored at the same index. + Returns \c true when \a result is added to the collection. + + Returns \c false when this promise is in cancelled or finished state or when + \a result is rejected. addResult() rejects \a result if there's already + another result in the collection stored at the same index. You can get a result at a specific index by calling QFuture::resultAt(). @@ -124,11 +128,6 @@ thinking if there are index gaps or not, use QFuture::results(). */ -/*! \fn template <typename T> void QPromise<T>::addResult(T &&result, int index = -1) - - \overload -*/ - /*! \fn template<typename T> void QPromise<T>::setException(const QException &e) Sets exception \a e to be the result of the computation. |