Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qfuturesynchronizer.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*! \class QFutureSynchronizer
5
\since 4.4
6
\inmodule QtCore
7
8
\brief The QFutureSynchronizer class is a convenience class that simplifies
9
QFuture synchronization.
10
11
\ingroup thread
12
13
QFutureSynchronizer is a template class where the template parameter \a T
14
specifies the result type of the QFuture objects being synchronized.
15
QFutureSynchronizer simplifies synchronization of one or more QFuture
16
objects. Futures are added using the addFuture() or setFuture() functions.
17
The futures() function returns a list of futures. Use clearFutures() to
18
remove all futures from the QFutureSynchronizer.
19
20
The waitForFinished() function waits for all futures to finish.
21
The destructor of QFutureSynchronizer calls waitForFinished(), providing
22
an easy way to ensure that all futures have finished before returning from
23
a function:
24
25
\snippet code/src_corelib_thread_qfuturesynchronizer.cpp 0
26
27
The behavior of waitForFinished() can be changed using the
28
setCancelOnWait() function. Calling setCancelOnWait(true) will cause
29
waitForFinished() to cancel all futures before waiting for them to finish.
30
You can query the status of the cancel-on-wait feature using the
31
cancelOnWait() function.
32
33
\sa QFuture, QFutureWatcher, {Qt Concurrent}
34
*/
35
36
/*!
37
\fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer()
38
39
Constructs a QFutureSynchronizer.
40
*/
41
42
/*!
43
\fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer(QFuture<T> future)
44
45
Constructs a QFutureSynchronizer and begins watching \a future by calling
46
addFuture().
47
48
\sa addFuture()
49
*/
50
51
/*!
52
\fn template <typename T> QFutureSynchronizer<T>::~QFutureSynchronizer()
53
54
Calls waitForFinished() function to ensure that all futures have finished
55
before destroying this QFutureSynchronizer.
56
57
\sa waitForFinished()
58
*/
59
60
/*!
61
\fn template <typename T> void QFutureSynchronizer<T>::setFuture(QFuture<T> future)
62
63
Sets \a future to be the only future managed by this QFutureSynchronizer.
64
This is a convenience function that calls waitForFinished(),
65
then clearFutures(), and finally passes \a future to addFuture().
66
67
\sa addFuture(), waitForFinished(), clearFutures()
68
*/
69
70
/*!
71
\fn template <typename T> void QFutureSynchronizer<T>::addFuture(QFuture<T> future)
72
73
Adds \a future to the list of managed futures.
74
75
\sa futures()
76
*/
77
78
/*!
79
\fn template <typename T> void QFutureSynchronizer<T>::waitForFinished()
80
81
Waits for all futures to finish. If cancelOnWait() returns \c true, each
82
future is canceled before waiting for them to finish.
83
84
\sa cancelOnWait(), setCancelOnWait()
85
*/
86
87
/*!
88
\fn template <typename T> void QFutureSynchronizer<T>::clearFutures()
89
90
Removes all managed futures from this QFutureSynchronizer.
91
92
\sa addFuture(), setFuture()
93
*/
94
95
/*!
96
\fn template <typename T> QList<QFuture<T> > QFutureSynchronizer<T>::futures() const
97
98
Returns a list of all managed futures.
99
100
\sa addFuture(), setFuture()
101
*/
102
103
/*!
104
\fn template <typename T> void QFutureSynchronizer<T>::setCancelOnWait(bool enabled)
105
106
Enables or disables the cancel-on-wait feature based on the \a enabled
107
argument. If \a enabled is true, the waitForFinished() function will cancel
108
all futures before waiting for them to finish.
109
110
\sa waitForFinished()
111
*/
112
113
/*!
114
\fn template <typename T> bool QFutureSynchronizer<T>::cancelOnWait() const
115
116
Returns \c true if the cancel-on-wait feature is enabled; otherwise returns
117
false. If cancel-on-wait is enabled, the waitForFinished() function will
118
cancel all futures before waiting for them to finish.
119
120
\sa waitForFinished()
121
*/
qtbase
src
corelib
thread
qfuturesynchronizer.qdoc
Generated on
for Qt by
1.16.1