1 | /****************************************************************************
|
---|
2 | ** $Id: qthread.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QThread class
|
---|
5 | **
|
---|
6 | ** Created : 931107
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QTHREAD_H
|
---|
39 | #define QTHREAD_H
|
---|
40 |
|
---|
41 | #if defined(QT_THREAD_SUPPORT)
|
---|
42 |
|
---|
43 | #ifndef QT_H
|
---|
44 | #include "qwindowdefs.h"
|
---|
45 | #ifndef QT_NO_COMPAT
|
---|
46 | #include "qmutex.h"
|
---|
47 | #include "qsemaphore.h"
|
---|
48 | #include "qwaitcondition.h"
|
---|
49 | #endif // QT_NO_COMPAT
|
---|
50 | #endif // QT_H
|
---|
51 |
|
---|
52 | #include <limits.h>
|
---|
53 |
|
---|
54 | class QThreadInstance;
|
---|
55 |
|
---|
56 | class Q_EXPORT QThread : public Qt
|
---|
57 | {
|
---|
58 | public:
|
---|
59 | static Qt::HANDLE currentThread();
|
---|
60 |
|
---|
61 | #ifndef QT_NO_COMPAT
|
---|
62 | static void postEvent( QObject *,QEvent * );
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | static void initialize();
|
---|
66 | static void cleanup();
|
---|
67 |
|
---|
68 | static void exit();
|
---|
69 |
|
---|
70 | #ifdef Q_QDOC
|
---|
71 | QThread( unsigned int stackSize = 0 );
|
---|
72 | #else
|
---|
73 | QThread( unsigned int stackSize );
|
---|
74 | QThread();
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | virtual ~QThread();
|
---|
78 |
|
---|
79 | // default argument causes thread to block indefinately
|
---|
80 | bool wait( unsigned long time = ULONG_MAX );
|
---|
81 |
|
---|
82 | enum Priority {
|
---|
83 | IdlePriority,
|
---|
84 |
|
---|
85 | LowestPriority,
|
---|
86 | LowPriority,
|
---|
87 | NormalPriority,
|
---|
88 | HighPriority,
|
---|
89 | HighestPriority,
|
---|
90 |
|
---|
91 | TimeCriticalPriority,
|
---|
92 |
|
---|
93 | InheritPriority
|
---|
94 | };
|
---|
95 |
|
---|
96 | #ifdef Q_QDOC
|
---|
97 | void start( Priority = InheritPriority );
|
---|
98 | #else
|
---|
99 | void start( Priority );
|
---|
100 | void start();
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | void terminate();
|
---|
104 |
|
---|
105 | bool finished() const;
|
---|
106 | bool running() const;
|
---|
107 |
|
---|
108 | protected:
|
---|
109 | virtual void run() = 0;
|
---|
110 |
|
---|
111 | static void sleep( unsigned long );
|
---|
112 | static void msleep( unsigned long );
|
---|
113 | static void usleep( unsigned long );
|
---|
114 |
|
---|
115 | private:
|
---|
116 | QThreadInstance * d;
|
---|
117 | friend class QThreadInstance;
|
---|
118 |
|
---|
119 | #if defined(Q_DISABLE_COPY)
|
---|
120 | QThread( const QThread & );
|
---|
121 | QThread &operator=( const QThread & );
|
---|
122 | #endif // Q_DISABLE_COPY
|
---|
123 | };
|
---|
124 |
|
---|
125 | #endif // QT_THREAD_SUPPORT
|
---|
126 |
|
---|
127 | #endif // QTHREAD_H
|
---|