author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QTHREAD_H |
|
43 |
#define QTHREAD_H |
|
44 |
||
45 |
#include <QtCore/qobject.h> |
|
46 |
||
47 |
#include <limits.h> |
|
48 |
||
49 |
QT_BEGIN_HEADER |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
53 |
QT_MODULE(Core) |
|
54 |
||
55 |
class QThreadData; |
|
56 |
class QThreadPrivate; |
|
57 |
||
58 |
#ifndef QT_NO_THREAD |
|
59 |
class Q_CORE_EXPORT QThread : public QObject |
|
60 |
{ |
|
61 |
public: |
|
62 |
static Qt::HANDLE currentThreadId(); |
|
63 |
static QThread *currentThread(); |
|
64 |
static int idealThreadCount(); |
|
65 |
static void yieldCurrentThread(); |
|
66 |
||
67 |
explicit QThread(QObject *parent = 0); |
|
68 |
~QThread(); |
|
69 |
||
70 |
enum Priority { |
|
71 |
IdlePriority, |
|
72 |
||
73 |
LowestPriority, |
|
74 |
LowPriority, |
|
75 |
NormalPriority, |
|
76 |
HighPriority, |
|
77 |
HighestPriority, |
|
78 |
||
79 |
TimeCriticalPriority, |
|
80 |
||
81 |
InheritPriority |
|
82 |
}; |
|
83 |
||
84 |
void setPriority(Priority priority); |
|
85 |
Priority priority() const; |
|
86 |
||
87 |
bool isFinished() const; |
|
88 |
bool isRunning() const; |
|
89 |
||
90 |
void setStackSize(uint stackSize); |
|
91 |
uint stackSize() const; |
|
92 |
||
93 |
void exit(int retcode = 0); |
|
94 |
||
95 |
public Q_SLOTS: |
|
96 |
void start(Priority = InheritPriority); |
|
97 |
void terminate(); |
|
98 |
void quit(); |
|
99 |
||
100 |
public: |
|
101 |
// default argument causes thread to block indefinately |
|
102 |
bool wait(unsigned long time = ULONG_MAX); |
|
103 |
||
104 |
Q_SIGNALS: |
|
105 |
void started(); |
|
106 |
void finished(); |
|
107 |
void terminated(); |
|
108 |
||
109 |
protected: |
|
110 |
virtual void run(); |
|
111 |
int exec(); |
|
112 |
||
113 |
static void setTerminationEnabled(bool enabled = true); |
|
114 |
||
115 |
static void sleep(unsigned long); |
|
116 |
static void msleep(unsigned long); |
|
117 |
static void usleep(unsigned long); |
|
118 |
||
119 |
#ifdef QT3_SUPPORT |
|
120 |
public: |
|
121 |
inline QT3_SUPPORT bool finished() const { return isFinished(); } |
|
122 |
inline QT3_SUPPORT bool running() const { return isRunning(); } |
|
123 |
#endif |
|
124 |
||
125 |
protected: |
|
126 |
QThread(QThreadPrivate &dd, QObject *parent = 0); |
|
127 |
||
128 |
private: |
|
129 |
Q_OBJECT |
|
130 |
Q_DECLARE_PRIVATE(QThread) |
|
131 |
||
132 |
static void initialize(); |
|
133 |
static void cleanup(); |
|
134 |
||
135 |
friend class QCoreApplication; |
|
136 |
friend class QThreadData; |
|
137 |
}; |
|
138 |
||
139 |
#else // QT_NO_THREAD |
|
140 |
||
141 |
class Q_CORE_EXPORT QThread : public QObject |
|
142 |
{ |
|
143 |
public: |
|
144 |
static Qt::HANDLE currentThreadId() { return Qt::HANDLE(currentThread()); } |
|
145 |
static QThread* currentThread(); |
|
146 |
||
147 |
protected: |
|
148 |
QThread(QThreadPrivate &dd, QObject *parent = 0); |
|
149 |
||
150 |
private: |
|
151 |
explicit QThread(QObject *parent = 0); |
|
152 |
static QThread *instance; |
|
153 |
||
154 |
friend class QCoreApplication; |
|
155 |
friend class QThreadData; |
|
156 |
friend class QAdoptedThread; |
|
157 |
Q_DECLARE_PRIVATE(QThread) |
|
158 |
}; |
|
159 |
||
160 |
#endif // QT_NO_THREAD |
|
161 |
||
162 |
QT_END_NAMESPACE |
|
163 |
||
164 |
QT_END_HEADER |
|
165 |
||
166 |
#endif // QTHREAD_H |