Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qfuturesynchronizer.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFUTURESYNCHRONIZER_H
5#define QFUTURESYNCHRONIZER_H
6
7#include <QtCore/qfuture.h>
8
10
12
13
14template <typename T>
16{
17 Q_DISABLE_COPY(QFutureSynchronizer)
18
19public:
21 Q_NODISCARD_CTOR_X("Use future.waitForFinished() instead.")
26
27 void setFuture(QFuture<T> future)
28 {
31 addFuture(std::move(future));
32 }
33
34 void addFuture(QFuture<T> future)
35 {
36 m_futures.append(std::move(future));
37 }
38
40 {
41 if (m_cancelOnWait) {
42 for (int i = 0; i < m_futures.size(); ++i) {
43 m_futures[i].cancel();
44 }
45 }
46
47 for (int i = 0; i < m_futures.size(); ++i) {
48 m_futures[i].waitForFinished();
49 }
50 }
51
53 {
55 }
56
57 QList<QFuture<T> > futures() const
58 {
59 return m_futures;
60 }
61
63 {
65 }
66
67 bool cancelOnWait() const
68 {
69 return m_cancelOnWait;
70 }
71
72protected:
73 QList<QFuture<T>> m_futures;
75};
76
78
79#endif // QFUTURESYNCHRONIZER_H
QList< QFuture< T > > m_futures
void addFuture(QFuture< T > future)
QList< QFuture< T > > futures() const
void setFuture(QFuture< T > future)
Q_NODISCARD_CTOR QFutureSynchronizer()
void setCancelOnWait(bool enabled)
qsizetype size() const noexcept
Definition qlist.h:397
void append(parameter_type t)
Definition qlist.h:458
void clear()
Definition qlist.h:434
Combined button and popup list for selecting options.
#define Q_NODISCARD_CTOR
#define Q_NODISCARD_CTOR_X(message)
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define QT_REQUIRE_CONFIG(feature)
#define enabled
#define explicit
QFuture< void > future
[5]