8#include <QtCore/qglobal.h>
10#include <QtCore/qfutureinterface.h>
11#include <QtCore/qmetatype.h>
12#include <QtCore/qstring.h>
14#include <QtCore/qfuture_impl.h>
28 static_assert (
std::is_move_constructible_v<T>
30 "A move-constructible type or type void is required");
69#if QT_DEPRECATED_SINCE(6
, 0
)
113 bool isResultReadyAt(
int resultIndex)
const {
return d.isResultReadyAt(resultIndex); }
132 template<
class Function>
135 template<
class Function>
138 template<
class Function>
141 template<
class Function>
144#ifndef QT_NO_EXCEPTIONS
171 static_assert(!
std::is_void_v<T>,
172 "It isn't possible to define QFuture<void>::const_iterator");
185 {
future = o.future; index = o.index;
return *
this; }
186 inline const T &
operator*()
const {
return future->d.resultReference(index); }
187 inline const T *
operator->()
const {
return future->d.resultPointer(index); }
189 { index = advanceIndex(index, 1);
return *
this; }
191 { index = advanceIndex(index, -1);
return *
this; }
195 index = advanceIndex(index, 1);
201 index = advanceIndex(index, -1);
209 { index = advanceIndex(index, j);
return *
this; }
211 { index = advanceIndex(index, -j);
return *
this; }
218 return lhs.index == rhs.index;
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
242 if (
idx == -1 &&
n >= 0)
277 friend class QFutureWatcher<
T>;
282 friend class QFutureInterfaceBase;
284 template<
class Function,
class ResultType,
class ParentResultType>
287 template<
class Function,
class ResultType>
290#ifndef QT_NO_EXCEPTIONS
291 template<
class Function,
class ResultType>
295 template<
typename ResultType>
306 mutable QFuturePrivate d;
310template<
typename U,
typename>
314 return d.resultReference(0);
318template<
typename U,
typename>
321 d.waitForResult(index);
322 return d.resultReference(index);
326inline QFuture<T> QFutureInterface<T>::future()
328 return QFuture<T>(
this);
332template<
class Function>
335 return then(QtFuture::Launch::Sync, std::forward<Function>(function));
339template<
class Function>
343 QFutureInterface<ResultType<Function>> promise(QFutureInterfaceBase::State::Pending);
344 QtPrivate::CompactContinuation<std::decay_t<Function>, ResultType<Function>, T>::create(
345 std::forward<Function>(function),
this, promise, policy);
346 return promise.future();
350template<
class Function>
354 QFutureInterface<ResultType<Function>> promise(QFutureInterfaceBase::State::Pending);
355 QtPrivate::CompactContinuation<std::decay_t<Function>, ResultType<Function>, T>::create(
356 std::forward<Function>(function),
this, promise, pool);
357 return promise.future();
361template<
class Function>
365 QFutureInterface<ResultType<Function>> promise(QFutureInterfaceBase::State::Pending);
366 QtPrivate::CompactContinuation<std::decay_t<Function>, ResultType<Function>, T>::create(
367 std::forward<Function>(function),
this, promise, context);
368 return promise.future();
371#ifndef QT_NO_EXCEPTIONS
373template<
class Function,
typename>
376 QFutureInterface<T> promise(QFutureInterfaceBase::State::Pending);
377 QtPrivate::FailureHandler<std::decay_t<Function>, T>::create(std::forward<Function>(handler),
379 return promise.future();
383template<
class Function,
typename>
386 QFutureInterface<T> promise(QFutureInterfaceBase::State::Pending);
387 QtPrivate::FailureHandler<std::decay_t<Function>, T>::create(std::forward<Function>(handler),
388 this, promise, context);
389 return promise.future();
395template<
class Function,
typename>
398 QFutureInterface<T> promise(QFutureInterfaceBase::State::Pending);
399 QtPrivate::CanceledHandler<std::decay_t<Function>, T>::create(std::forward<Function>(handler),
401 return promise.future();
405template<
class Function,
typename>
408 QFutureInterface<T> promise(QFutureInterfaceBase::State::Pending);
409 QtPrivate::CanceledHandler<std::decay_t<Function>, T>::create(std::forward<Function>(handler),
410 this, promise, context);
411 return promise.future();
415template<
class U,
typename>
418 if constexpr (QtPrivate::isQFutureV<
typename QtPrivate::Future<T>::type>)
419 return QtPrivate::UnwrapHandler::unwrapImpl(
this).unwrap();
421 return QtPrivate::UnwrapHandler::unwrapImpl(
this);
424inline QFuture<
void> QFutureInterface<
void>::future()
426 return QFuture<
void>(
this);
430QFutureInterfaceBase QFutureInterfaceBase::get(
const QFuture<T> &future)
442 if constexpr (
std::is_void_v<T>) {
445 return QMetaType::registerConverter<QFuture<T>, QFuture<
void>>(
446 [](
const QFuture<T> &future) {
return QFuture<
void>(future); });
457template<
typename OutputSequence,
typename InputIt,
458 typename ValueType =
typename std::iterator_traits<InputIt>::value_type,
468template<
typename InputIt,
typename ValueType =
typename std::iterator_traits<InputIt>::value_type,
497template<
typename InputIt,
typename ValueType =
typename std::iterator_traits<InputIt>::value_type,
524template<
typename T,
typename InputIt>
532#if QT_DEPRECATED_SINCE(6
, 10
)
536template<
typename T =
void>
547Q_DECLARE_SEQUENTIAL_ITERATOR(Future)
551Q_DECLARE_METATYPE_TEMPLATE_1ARG(QFuture)
bool internal_updateProgress(int progress, const QString &progressText=QString())
void sendCallOuts(const QFutureCallOutEvent &callOut1, const QFutureCallOutEvent &callOut2)
void sendCallOut(const QFutureCallOutEvent &callOut)
bool internal_waitForNextResult()
void setState(QFutureInterfaceBase::State state)
bool internal_updateProgressValue(int progress)
bool internal_isResultReadyAt(int index) const
void internal_setThrottled(bool enable)
int internal_resultCount() const
~QFutureInterfaceBasePrivate()
QFutureInterfaceBasePrivate * continuationData
QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState)
const_iterator & operator-=(int j)
const_iterator operator-(int j) const
std::bidirectional_iterator_tag iterator_category
const_iterator operator++(int)
const_iterator operator--(int)
const_iterator & operator++()
const_iterator(const const_iterator &o)
friend const_iterator operator+(int j, const_iterator k)
const_iterator & operator--()
const_iterator & operator+=(int j)
const_iterator operator+(int j) const
friend bool comparesEqual(const const_iterator &lhs, const const_iterator &rhs) noexcept
const T * operator->() const
const_iterator(QFuture const *const _future, int _index)
const T & operator*() const
const_iterator & operator=(const const_iterator &o)
QFuture< ResultType< Function > > then(Function &&function)
typename QtPrivate::ResultTypeHelper< Function, T >::ResultType ResultType
friend struct QtPrivate::WhenAnyContext
friend class QtPrivate::CanceledHandler
QList< T > results() const
friend class QtPrivate::CompactContinuation
QFuture< ResultType< Function > > then(QThreadPool *pool, Function &&function)
T resultAt(int index) const
const_iterator end() const
const_iterator begin() const
const_iterator ConstIterator
QFuture< typename QFuture< T >::template ResultType< Function > > then(Function &&function)
QFuture< T > onCanceled(Function &&handler)
QFuture< typename QFuture< T >::template ResultType< Function > > then(QtFuture::Launch policy, Function &&function)
QFuture< typename QFuture< T >::template ResultType< Function > > then(QThreadPool *pool, Function &&function)
QFuture< T > onCanceled(QObject *context, Function &&handler)
const_iterator constEnd() const
friend class QtPrivate::FailureHandler
bool isResultReadyAt(int resultIndex) const
const_iterator constBegin() const
QFuture< ResultType< Function > > then(QtFuture::Launch policy, Function &&function)
QFuture< void > makeReadyVoidFuture()
void qfutureWarnIfUnusedResults(qsizetype numResults)
static int switch_from_to(QAtomicInt &a, int from, int to)
static int switch_off(QAtomicInt &a, int which)
static int switch_on(QAtomicInt &a, int which)
QFuture< void > future
[5]