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.h | |
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.h')
-rw-r--r-- | src/corelib/thread/qpromise.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/thread/qpromise.h b/src/corelib/thread/qpromise.h index 59c31de212..4225abd771 100644 --- a/src/corelib/thread/qpromise.h +++ b/src/corelib/thread/qpromise.h @@ -89,9 +89,9 @@ public: template<typename U = T, typename = QtPrivate::EnableForNonVoid<std::decay_t<U>>, typename = QtPrivate::EnableIfSameOrConvertible<std::decay_t<U>, std::decay_t<T>>> - void addResult(U &&result, int index = -1) + bool addResult(U &&result, int index = -1) { - d.reportResult(std::forward<U>(result), index); + return d.reportResult(std::forward<U>(result), index); } #ifndef QT_NO_EXCEPTIONS void setException(const QException &e) { d.reportException(e); } @@ -118,8 +118,8 @@ public: } #if defined(Q_CLANG_QDOC) // documentation-only simplified signatures - void addResult(const T &result, int index = -1) { } - void addResult(T &&result, int index = -1) { } + bool addResult(const T &result, int index = -1) { } + bool addResult(T &&result, int index = -1) { } #endif private: mutable QFutureInterface<T> d = QFutureInterface<T>(); |