source: trunk/src/corelib/concurrent/qfuturesynchronizer.cpp@ 104

Last change on this file since 104 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtCore module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*! \class QFutureSynchronizer
43 \since 4.4
44
45 \brief The QFutureSynchronizer class is a convenience class that simplifies
46 QFuture synchronization.
47
48 QFutureSynchronizer is a template class that simplifies synchronization of
49 one or more QFuture objects. Futures are added using the addFuture() or
50 setFuture() functions. The futures() function returns a list of futures.
51 Use clearFutures() to remove all futures from the QFutureSynchronizer.
52
53 The waitForFinished() function waits for all futures to finish.
54 The destructor of QFutureSynchronizer calls waitForFinished(), providing
55 an easy way to ensure that all futures have finished before returning from
56 a function:
57
58 \snippet doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp 0
59
60 The behavior of waitForFinished() can be changed using the
61 setCancelOnWait() function. Calling setCancelOnWait(true) will cause
62 waitForFinished() to cancel all futures before waiting for them to finish.
63 You can query the status of the cancel-on-wait feature using the
64 cancelOnWait() function.
65
66 \sa QFuture, QFutureWatcher, {threads.html#qtconcurrent-intro}{Qt Concurrent}
67*/
68
69/*!
70 \fn QFutureSynchronizer::QFutureSynchronizer()
71
72 Constructs a QFutureSynchronizer.
73*/
74
75/*!
76 \fn QFutureSynchronizer::QFutureSynchronizer(const QFuture<T> &future)
77
78 Constructs a QFutureSynchronizer and begins watching \a future by calling
79 addFuture().
80
81 \sa addFuture()
82*/
83
84/*!
85 \fn QFutureSynchronizer::~QFutureSynchronizer()
86
87 Calls waitForFinished() function to ensure that all futures have finished
88 before destroying this QFutureSynchronizer.
89
90 \sa waitForFinished()
91*/
92
93/*!
94 \fn void QFutureSynchronizer::setFuture(const QFuture<T> &future)
95
96 Sets \a future to be the only future managed by this QFutureSynchronizer.
97 This is a convenience function that calls waitForFinished(),
98 then clearFutures(), and finally passes \a future to addFuture().
99
100 \sa addFuture(), waitForFinished(), clearFutures()
101*/
102
103/*!
104 \fn void QFutureSynchronizer::addFuture(const QFuture<T> &future)
105
106 Adds \a future to the list of managed futures.
107
108 \sa futures()
109*/
110
111/*!
112 \fn void QFutureSynchronizer::waitForFinished()
113
114 Waits for all futures to finish. If cancelOnWait() returns true, each
115 future is canceled before waiting for them to finish.
116
117 \sa cancelOnWait(), setCancelOnWait()
118*/
119
120/*!
121 \fn void QFutureSynchronizer::clearFutures()
122
123 Removes all managed futures from this QFutureSynchronizer.
124
125 \sa addFuture(), setFuture()
126*/
127
128/*!
129 \fn QList<QFuture<T> > QFutureSynchronizer::futures() const
130
131 Returns a list of all managed futures.
132
133 \sa addFuture(), setFuture()
134*/
135
136/*!
137 \fn void QFutureSynchronizer::setCancelOnWait(bool enabled)
138
139 Enables or disables the cancel-on-wait feature based on the \a enabled
140 argument. If \a enabled is true, the waitForFinished() function will cancel
141 all futures before waiting for them to finish.
142
143 \sa waitForFinished()
144*/
145
146/*!
147 \fn bool QFutureSynchronizer::cancelOnWait() const
148
149 Returns true if the cancel-on-wait feature is enabled; otherwise returns
150 false. If cancel-on-wait is enabled, the waitForFinished() function will
151 cancel all futures before waiting for them to finish.
152
153 \sa waitForFinished()
154*/
Note: See TracBrowser for help on using the repository browser.