Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QTHREAD_H
00043 #define QTHREAD_H
00044
00045 #include <QtCore/qobject.h>
00046
00047 #include <limits.h>
00048
00049 QT_BEGIN_HEADER
00050
00051 QT_BEGIN_NAMESPACE
00052
00053 QT_MODULE(Core)
00054
00055 class QThreadData;
00056 class QThreadPrivate;
00057
00058 #ifndef QT_NO_THREAD
00059 class Q_CORE_EXPORT QThread : public QObject
00060 {
00061 public:
00062 static Qt::HANDLE currentThreadId();
00063 static QThread *currentThread();
00064 static int idealThreadCount();
00065 static void yieldCurrentThread();
00066
00067 explicit QThread(QObject *parent = 0);
00068 ~QThread();
00069
00070 enum Priority {
00071 IdlePriority,
00072
00073 LowestPriority,
00074 LowPriority,
00075 NormalPriority,
00076 HighPriority,
00077 HighestPriority,
00078
00079 TimeCriticalPriority,
00080
00081 InheritPriority
00082 };
00083
00084 void setPriority(Priority priority);
00085 Priority priority() const;
00086
00087 bool isFinished() const;
00088 bool isRunning() const;
00089
00090 void setStackSize(uint stackSize);
00091 uint stackSize() const;
00092
00093 void exit(int retcode = 0);
00094
00095 public Q_SLOTS:
00096 void start(Priority = InheritPriority);
00097 void terminate();
00098 void quit();
00099
00100 public:
00101
00102 bool wait(unsigned long time = ULONG_MAX);
00103
00104 Q_SIGNALS:
00105 void started();
00106 void finished();
00107 void terminated();
00108
00109 protected:
00110 virtual void run();
00111 int exec();
00112
00113 static void setTerminationEnabled(bool enabled = true);
00114
00115 static void sleep(unsigned long);
00116 static void msleep(unsigned long);
00117 static void usleep(unsigned long);
00118
00119 #ifdef QT3_SUPPORT
00120 public:
00121 inline QT3_SUPPORT bool finished() const { return isFinished(); }
00122 inline QT3_SUPPORT bool running() const { return isRunning(); }
00123 #endif
00124
00125 protected:
00126 QThread(QThreadPrivate &dd, QObject *parent = 0);
00127
00128 private:
00129 Q_OBJECT
00130 Q_DECLARE_PRIVATE(QThread)
00131
00132 static void initialize();
00133 static void cleanup();
00134
00135 friend class QCoreApplication;
00136 friend class QThreadData;
00137 };
00138
00139 #else // QT_NO_THREAD
00140
00141 class Q_CORE_EXPORT QThread : public QObject
00142 {
00143 public:
00144 static Qt::HANDLE currentThreadId() { return Qt::HANDLE(currentThread()); }
00145 static QThread* currentThread();
00146
00147 protected:
00148 QThread(QThreadPrivate &dd, QObject *parent = 0);
00149
00150 private:
00151 explicit QThread(QObject *parent = 0);
00152 static QThread *instance;
00153
00154 friend class QCoreApplication;
00155 friend class QThreadData;
00156 friend class QAdoptedThread;
00157 Q_DECLARE_PRIVATE(QThread)
00158 };
00159
00160 #endif // QT_NO_THREAD
00161
00162 QT_END_NAMESPACE
00163
00164 QT_END_HEADER
00165
00166 #endif // QTHREAD_H