Qt 4.8
qtconcurrentrun.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 // Generated code, do not edit! Use generator at tools/qtconcurrent/generaterun/
43 #ifndef QTCONCURRENT_RUN_H
44 #define QTCONCURRENT_RUN_H
45 
46 #include <QtCore/qglobal.h>
47 
48 #ifndef QT_NO_CONCURRENT
49 
50 #include <QtCore/qtconcurrentrunbase.h>
51 #include <QtCore/qtconcurrentstoredfunctioncall.h>
52 
55 
56 QT_MODULE(Core)
57 
58 #ifdef qdoc
59 
60 namespace QtConcurrent {
61 
62  template <typename T>
63  QFuture<T> run(Function function, ...);
64 
65 } // namespace QtConcurrent
66 
67 #else
68 
69 namespace QtConcurrent {
70 
71 template <typename T>
72 QFuture<T> run(T (*functionPointer)())
73 {
74  return (new StoredFunctorCall0<T, T (*)()>(functionPointer))->start();
75 }
76 template <typename T, typename Param1, typename Arg1>
77 QFuture<T> run(T (*functionPointer)(Param1), const Arg1 &arg1)
78 {
79  return (new StoredFunctorCall1<T, T (*)(Param1), Arg1>(functionPointer, arg1))->start();
80 }
81 template <typename T, typename Param1, typename Arg1, typename Param2, typename Arg2>
82 QFuture<T> run(T (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
83 {
84  return (new StoredFunctorCall2<T, T (*)(Param1, Param2), Arg1, Arg2>(functionPointer, arg1, arg2))->start();
85 }
86 template <typename T, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3>
87 QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
88 {
89  return (new StoredFunctorCall3<T, T (*)(Param1, Param2, Param3), Arg1, Arg2, Arg3>(functionPointer, arg1, arg2, arg3))->start();
90 }
91 template <typename T, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4>
92 QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
93 {
94  return (new StoredFunctorCall4<T, T (*)(Param1, Param2, Param3, Param4), Arg1, Arg2, Arg3, Arg4>(functionPointer, arg1, arg2, arg3, arg4))->start();
95 }
96 template <typename T, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
97 QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
98 {
99  return (new StoredFunctorCall5<T, T (*)(Param1, Param2, Param3, Param4, Param5), Arg1, Arg2, Arg3, Arg4, Arg5>(functionPointer, arg1, arg2, arg3, arg4, arg5))->start();
100 }
101 
102 #if defined(Q_COMPILER_DECLTYPE) && defined(Q_COMPILER_AUTO_FUNCTION)
103 
104 template <typename Functor>
106 {
107  typedef decltype(functor()) result_type;
108  return (new StoredFunctorCall0<result_type, Functor>(functor))->start();
109 }
110 
111 template <typename Functor, typename Arg1>
112 auto run(Functor functor, const Arg1 &arg1)
113  -> typename QtPrivate::QEnableIf<!QtPrivate::HasResultType<Functor>::Value, QFuture<decltype(functor(arg1))> >::Type
114 {
115  typedef decltype(functor(arg1)) result_type;
116  return (new StoredFunctorCall1<result_type, Functor, Arg1>(functor, arg1))->start();
117 }
118 
119 template <typename Functor, typename Arg1, typename Arg2>
120 auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2)
122 {
123  typedef decltype(functor(arg1, arg2)) result_type;
124  return (new StoredFunctorCall2<result_type, Functor, Arg1, Arg2>(functor, arg1, arg2))->start();
125 }
126 
127 template <typename Functor, typename Arg1, typename Arg2, typename Arg3>
128 auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
130 {
131  typedef decltype(functor(arg1, arg2, arg3)) result_type;
132  return (new StoredFunctorCall3<result_type, Functor, Arg1, Arg2, Arg3>(functor, arg1, arg2, arg3))->start();
133 }
134 
135 template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
136 auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
138 {
139  typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type;
140  return (new StoredFunctorCall4<result_type, Functor, Arg1, Arg2, Arg3, Arg4>(functor, arg1, arg2, arg3, arg4))->start();
141 }
142 
143 template <typename Functor, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
144 auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
146 {
147  typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type;
148  return (new StoredFunctorCall5<result_type, Functor, Arg1, Arg2, Arg3, Arg4, Arg5>(functor, arg1, arg2, arg3, arg4, arg5))->start();
149 }
150 
151 #endif
152 
153 template <typename FunctionObject>
154 QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject)
155 {
156  return (new StoredFunctorCall0<QT_TYPENAME FunctionObject::result_type, FunctionObject>(functionObject))->start();
157 }
158 template <typename FunctionObject, typename Arg1>
159 QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1)
160 {
161  return (new StoredFunctorCall1<QT_TYPENAME FunctionObject::result_type, FunctionObject, Arg1>(functionObject, arg1))->start();
162 }
163 template <typename FunctionObject, typename Arg1, typename Arg2>
164 QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2)
165 {
166  return (new StoredFunctorCall2<QT_TYPENAME FunctionObject::result_type, FunctionObject, Arg1, Arg2>(functionObject, arg1, arg2))->start();
167 }
168 template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3>
169 QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
170 {
171  return (new StoredFunctorCall3<QT_TYPENAME FunctionObject::result_type, FunctionObject, Arg1, Arg2, Arg3>(functionObject, arg1, arg2, arg3))->start();
172 }
173 template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
174 QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
175 {
176  return (new StoredFunctorCall4<QT_TYPENAME FunctionObject::result_type, FunctionObject, Arg1, Arg2, Arg3, Arg4>(functionObject, arg1, arg2, arg3, arg4))->start();
177 }
178 template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
179 QFuture<typename FunctionObject::result_type> run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
180 {
181  return (new StoredFunctorCall5<QT_TYPENAME FunctionObject::result_type, FunctionObject, Arg1, Arg2, Arg3, Arg4, Arg5>(functionObject, arg1, arg2, arg3, arg4, arg5))->start();
182 }
183 
184 template <typename FunctionObject>
185 QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject)
186 {
188 }
189 template <typename FunctionObject, typename Arg1>
190 QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1)
191 {
193 }
194 template <typename FunctionObject, typename Arg1, typename Arg2>
195 QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2)
196 {
198 }
199 template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3>
200 QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
201 {
203 }
204 template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
205 QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
206 {
208 }
209 template <typename FunctionObject, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
210 QFuture<typename FunctionObject::result_type> run(FunctionObject *functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
211 {
213 }
214 
215 template <typename T, typename Class>
216 QFuture<T> run(const Class &object, T (Class::*fn)())
217 {
218  return (new QT_TYPENAME SelectStoredMemberFunctionCall0<T, Class>::type(fn, object))->start();
219 }
220 template <typename T, typename Class, typename Param1, typename Arg1>
221 QFuture<T> run(const Class &object, T (Class::*fn)(Param1), const Arg1 &arg1)
222 {
223  return (new QT_TYPENAME SelectStoredMemberFunctionCall1<T, Class, Param1, Arg1>::type(fn, object, arg1))->start();
224 }
225 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2>
226 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
227 {
229 }
230 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3>
231 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
232 {
234 }
235 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4>
236 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
237 {
239 }
240 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
241 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
242 {
244 }
245 
246 template <typename T, typename Class>
247 QFuture<T> run(const Class &object, T (Class::*fn)() const)
248 {
249  return (new QT_TYPENAME SelectStoredConstMemberFunctionCall0<T, Class>::type(fn, object))->start();
250 }
251 template <typename T, typename Class, typename Param1, typename Arg1>
252 QFuture<T> run(const Class &object, T (Class::*fn)(Param1) const, const Arg1 &arg1)
253 {
255 }
256 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2>
257 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2)
258 {
260 }
261 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3>
262 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
263 {
265 }
266 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4>
267 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
268 {
270 }
271 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
272 QFuture<T> run(const Class &object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
273 {
275 }
276 
277 template <typename T, typename Class>
278 QFuture<T> run(Class *object, T (Class::*fn)())
279 {
281 }
282 template <typename T, typename Class, typename Param1, typename Arg1>
283 QFuture<T> run(Class *object, T (Class::*fn)(Param1), const Arg1 &arg1)
284 {
286 }
287 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2>
288 QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
289 {
291 }
292 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3>
293 QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
294 {
296 }
297 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4>
298 QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
299 {
301 }
302 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
303 QFuture<T> run(Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
304 {
306 }
307 
308 template <typename T, typename Class>
309 QFuture<T> run(const Class *object, T (Class::*fn)() const)
310 {
312 }
313 template <typename T, typename Class, typename Param1, typename Arg1>
314 QFuture<T> run(const Class *object, T (Class::*fn)(Param1) const, const Arg1 &arg1)
315 {
317 }
318 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2>
319 QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2) const, const Arg1 &arg1, const Arg2 &arg2)
320 {
322 }
323 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3>
324 QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2, Param3) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
325 {
327 }
328 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4>
329 QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
330 {
332 }
333 template <typename T, typename Class, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
334 QFuture<T> run(const Class *object, T (Class::*fn)(Param1, Param2, Param3, Param4, Param5) const, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
335 {
337 }
338 
339 } //namespace QtConcurrent
340 
341 #endif // qdoc
342 
345 
346 #endif // QT_NO_CONCURRENT
347 
348 #endif
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QFuture class represents the result of an asynchronous computation.
Definition: qfuture.h:64
The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded pro...
#define QT_TYPENAME
QFuture< T > run(Function function,...)
static Bool functor(Display *display, XEvent *event, XPointer arg)
return(isPopup||isToolTip)
#define QT_END_HEADER
Definition: qglobal.h:137