Qt 4.8
qfutureinterface_p.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 #ifndef QFUTUREINTERFACE_P_H
43 #define QFUTUREINTERFACE_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qelapsedtimer.h>
57 #include <QtCore/qcoreevent.h>
58 #include <QtCore/qlist.h>
59 #include <QtCore/qwaitcondition.h>
60 #include <QtCore/qrunnable.h>
61 
63 
65 {
66 public:
67  enum CallOutType {
76  };
77 
80  { }
82  : QEvent(QEvent::FutureCallOut), callOutType(callOutType), index1(index1), index2(-1)
83  { }
85  : QEvent(QEvent::FutureCallOut), callOutType(callOutType), index1(index1), index2(index2)
86  { }
87 
90  callOutType(callOutType),
91  index1(index1),
92  index2(-1),
93  text(text)
94  { }
95 
97  int index1;
98  int index2;
100 
102  {
103  return new QFutureCallOutEvent(callOutType, index1, index2, text);
104  }
105 
106 private:
108  int index1,
109  int index2,
110  const QString &text)
112  callOutType(callOutType),
113  index1(index1),
114  index2(index2),
115  text(text)
116  { }
117 };
118 
120 {
121 public:
123  virtual void postCallOutEvent(const QFutureCallOutEvent &) = 0;
124  virtual void callOutInterfaceDisconnected() = 0;
125 };
126 
128 {
129 public:
131 
133  mutable QMutex m_mutex;
143  QtConcurrent::ResultStoreBase m_results;
149 
150  // Internal functions that does not change the mutex state.
151  // The mutex must be locked when calling these.
152  int internal_resultCount() const;
153  bool internal_isResultReadyAt(int index) const;
154  bool internal_waitForNextResult();
155  bool internal_updateProgress(int progress, const QString &progressText = QString());
156  void internal_setThrottled(bool enable);
157  void sendCallOut(const QFutureCallOutEvent &callOut);
158  void sendCallOuts(const QFutureCallOutEvent &callOut1, const QFutureCallOutEvent &callOut2);
159  void connectOutputInterface(QFutureCallOutInterface *iface);
160  void disconnectOutputInterface(QFutureCallOutInterface *iface);
161 
162  void setState(QFutureInterfaceBase::State state);
163 };
164 
166 
167 #endif
QFutureCallOutEvent(CallOutType callOutType, int index1, const QString &text)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
The QAtomicInt class provides platform-independent atomic operations on integers. ...
Definition: qatomic.h:55
QFutureCallOutEvent(CallOutType callOutType, int index1, int index2, const QString &text)
QtConcurrent::ResultStoreBase m_results
QFutureInterfaceBase::State state
QFutureCallOutEvent * clone() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
The QRunnable class is the base class for all runnable objects.
Definition: qrunnable.h:52
QtConcurrent::internal::ExceptionStore m_exceptionStore
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QFutureCallOutEvent(CallOutType callOutType, int index1=-1)
QList< QFutureCallOutInterface * > outputConnections
quint16 index
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
QFutureCallOutEvent(CallOutType callOutType, int index1, int index2)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62