Merge integration refs/builds/qtci/dev/1616406519

This commit is contained in:
Qt CI Bot 2021-03-22 15:19:48 +00:00
commit b4afffd6a2
4 changed files with 25 additions and 14 deletions

View File

@ -48,7 +48,6 @@
#include <QtCore/qfuture_impl.h>
#include <type_traits>
#include <vector>
QT_REQUIRE_CONFIG(future);

View File

@ -600,6 +600,11 @@ void QFutureInterfaceBase::reset()
d->isValid = false;
}
void QFutureInterfaceBase::rethrowPossibleException()
{
exceptionStore().throwPossibleException();
}
QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState)
: refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0),
state(initialState),

View File

@ -40,17 +40,19 @@
#ifndef QFUTUREINTERFACE_H
#define QFUTUREINTERFACE_H
#include <QtCore/qrunnable.h>
#include <QtCore/qmutex.h>
#include <QtCore/qexception.h>
#include <QtCore/QMutexLocker>
#include <QtCore/qresultstore.h>
#ifndef QT_NO_EXCEPTIONS
#include <exception>
#endif
#include <utility>
#include <vector>
#include <mutex>
QT_REQUIRE_CONFIG(future);
QT_FORWARD_DECLARE_CLASS(QRunnable)
QT_FORWARD_DECLARE_CLASS(QException)
QT_BEGIN_NAMESPACE
@ -64,6 +66,8 @@ namespace QtPrivate {
template<typename Function, typename ResultType, typename ParentResultType>
class Continuation;
class ExceptionStore;
template<class Function, class ResultType>
class CanceledHandler;
@ -169,6 +173,7 @@ protected:
bool refT() const;
bool derefT() const;
void reset();
void rethrowPossibleException();
public:
#ifndef QFUTURE_TEST
@ -262,7 +267,7 @@ public:
template <typename T>
inline bool QFutureInterface<T>::reportResult(const T *result, int index)
{
std::lock_guard<QMutex> locker{mutex()};
QMutexLocker<QMutex> locker{&mutex()};
if (this->queryState(Canceled) || this->queryState(Finished))
return false;
@ -283,7 +288,7 @@ inline bool QFutureInterface<T>::reportResult(const T *result, int index)
template<typename T>
bool QFutureInterface<T>::reportAndMoveResult(T &&result, int index)
{
std::lock_guard<QMutex> locker{mutex()};
QMutexLocker<QMutex> locker{&mutex()};
if (queryState(Canceled) || queryState(Finished))
return false;
@ -312,7 +317,7 @@ inline bool QFutureInterface<T>::reportResult(const T &result, int index)
template<typename T>
inline bool QFutureInterface<T>::reportResults(const QList<T> &_results, int beginIndex, int count)
{
std::lock_guard<QMutex> locker{mutex()};
QMutexLocker<QMutex> locker{&mutex()};
if (this->queryState(Canceled) || this->queryState(Finished))
return false;
@ -343,14 +348,14 @@ inline bool QFutureInterface<T>::reportFinished(const T *result)
template <typename T>
inline const T &QFutureInterface<T>::resultReference(int index) const
{
std::lock_guard<QMutex> locker{mutex()};
QMutexLocker<QMutex> locker{&mutex()};
return resultStoreBase().resultAt(index).template value<T>();
}
template <typename T>
inline const T *QFutureInterface<T>::resultPointer(int index) const
{
std::lock_guard<QMutex> locker{mutex()};
QMutexLocker<QMutex> locker{&mutex()};
return resultStoreBase().resultAt(index).template pointer<T>();
}
@ -358,14 +363,14 @@ template <typename T>
inline QList<T> QFutureInterface<T>::results()
{
if (this->isCanceled()) {
exceptionStore().throwPossibleException();
rethrowPossibleException();
return QList<T>();
}
QFutureInterfaceBase::waitForResult(-1);
QList<T> res;
std::lock_guard<QMutex> locker{mutex()};
QMutexLocker<QMutex> locker{&mutex()};
QtPrivate::ResultIteratorBase it = resultStoreBase().begin();
while (it != resultStoreBase().end()) {
@ -385,7 +390,7 @@ T QFutureInterface<T>::takeResult()
// not to mess with other unready results.
waitForResult(-1);
const std::lock_guard<QMutex> locker{mutex()};
const QMutexLocker<QMutex> locker{&mutex()};
QtPrivate::ResultIteratorBase position = resultStoreBase().resultAt(0);
T ret(std::move_if_noexcept(position.value<T>()));
reset();
@ -404,7 +409,7 @@ std::vector<T> QFutureInterface<T>::takeResults()
std::vector<T> res;
res.reserve(resultCount());
const std::lock_guard<QMutex> locker{mutex()};
const QMutexLocker<QMutex> locker{&mutex()};
QtPrivate::ResultIteratorBase it = resultStoreBase().begin();
for (auto endIt = resultStoreBase().end(); it != endIt; ++it)

View File

@ -58,6 +58,8 @@
#include <QtCore/qwaitcondition.h>
#include <QtCore/qrunnable.h>
#include <QtCore/qthreadpool.h>
#include <QtCore/qfutureinterface.h>
#include <QtCore/qexception.h>
QT_REQUIRE_CONFIG(future);