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 that simplifies synchronization of
14
one or more QFuture objects. Futures are added using the addFuture() or
15
setFuture() functions. The futures() function returns a list of futures.
16
Use clearFutures() to remove all futures from the QFutureSynchronizer.
17
18
The waitForFinished() function waits for all futures to finish.
19
The destructor of QFutureSynchronizer calls waitForFinished(), providing
20
an easy way to ensure that all futures have finished before returning from
21
a function:
22
23
\snippet code/src_corelib_thread_qfuturesynchronizer.cpp 0
24
25
The behavior of waitForFinished() can be changed using the
26
setCancelOnWait() function. Calling setCancelOnWait(true) will cause
27
waitForFinished() to cancel all futures before waiting for them to finish.
28
You can query the status of the cancel-on-wait feature using the
29
cancelOnWait() function.
30
31
\sa QFuture, QFutureWatcher, {Qt Concurrent}
32
*/
33
34
/*!
35
\fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer()
36
37
Constructs a QFutureSynchronizer.
38
*/
39
40
/*!
41
\fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer(QFuture<T> future)
42
43
Constructs a QFutureSynchronizer and begins watching \a future by calling
44
addFuture().
45
46
\sa addFuture()
47
*/
48
49
/*!
50
\fn template <typename T> QFutureSynchronizer<T>::~QFutureSynchronizer()
51
52
Calls waitForFinished() function to ensure that all futures have finished
53
before destroying this QFutureSynchronizer.
54
55
\sa waitForFinished()
56
*/
57
58
/*!
59
\fn template <typename T> void QFutureSynchronizer<T>::setFuture(QFuture<T> future)
60
61
Sets \a future to be the only future managed by this QFutureSynchronizer.
62
This is a convenience function that calls waitForFinished(),
63
then clearFutures(), and finally passes \a future to addFuture().
64
65
\sa addFuture(), waitForFinished(), clearFutures()
66
*/
67
68
/*!
69
\fn template <typename T> void QFutureSynchronizer<T>::addFuture(QFuture<T> future)
70
71
Adds \a future to the list of managed futures.
72
73
\sa futures()
74
*/
75
76
/*!
77
\fn template <typename T> void QFutureSynchronizer<T>::waitForFinished()
78
79
Waits for all futures to finish. If cancelOnWait() returns \c true, each
80
future is canceled before waiting for them to finish.
81
82
\sa cancelOnWait(), setCancelOnWait()
83
*/
84
85
/*!
86
\fn template <typename T> void QFutureSynchronizer<T>::clearFutures()
87
88
Removes all managed futures from this QFutureSynchronizer.
89
90
\sa addFuture(), setFuture()
91
*/
92
93
/*!
94
\fn template <typename T> QList<QFuture<T> > QFutureSynchronizer<T>::futures() const
95
96
Returns a list of all managed futures.
97
98
\sa addFuture(), setFuture()
99
*/
100
101
/*!
102
\fn template <typename T> void QFutureSynchronizer<T>::setCancelOnWait(bool enabled)
103
104
Enables or disables the cancel-on-wait feature based on the \a enabled
105
argument. If \a enabled is true, the waitForFinished() function will cancel
106
all futures before waiting for them to finish.
107
108
\sa waitForFinished()
109
*/
110
111
/*!
112
\fn template <typename T> bool QFutureSynchronizer<T>::cancelOnWait() const
113
114
Returns \c true if the cancel-on-wait feature is enabled; otherwise returns
115
false. If cancel-on-wait is enabled, the waitForFinished() function will
116
cancel all futures before waiting for them to finish.
117
118
\sa waitForFinished()
119
*/
qtbase
src
corelib
thread
qfuturesynchronizer.qdoc
Generated on Mon Mar 10 2025 01:10:21 for Qt by
1.13.2