53 #include "private/qcoreapplication_p.h" 80 : _ref(initialRefCount), thread(0), threadId(0),
81 quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false)
108 --pe.
receiver->d_func()->postedEvents;
143 d_func()->running =
true;
166 qFatal(
"QAdoptedThread::run(): Internal error, this implementation should never be called.");
175 isInFinish(false), exited(false), returnCode(-1),
178 #if defined (Q_OS_UNIX) 180 #elif defined (Q_WS_WIN) 185 #if defined (Q_WS_WIN) || defined (Q_OS_SYMBIAN) 438 d->data->thread =
this;
448 d->data->thread =
this;
470 if (
d->running && !
d->finished && !
d->data->isAdopted)
471 qWarning(
"QThread: Destroyed while thread is still running");
486 return d->finished ||
d->isInFinish;
501 if (
d->data->symbian_thread_handle.Handle() &&
d->data->symbian_thread_handle.ExitType() != EExitPending)
504 return d->running && !
d->isInFinish;
524 "cannot change stack size while the thread is running");
555 d->data->quitNow =
false;
558 return d->returnCode;
563 int returnCode = eventLoop.
exec();
597 d->returnCode = returnCode;
598 d->data->quitNow =
true;
599 for (
int i = 0; i <
d->data->eventLoops.size(); ++i) {
601 eventLoop->
exit(returnCode);
639 #if defined (Q_OS_WIN) 649 #if defined (Q_OS_WIN) 839 #else // QT_NO_THREAD 844 d->data->thread =
this;
858 data = newdata.
take();
871 d->data->thread =
this;
874 #endif // QT_NO_THREAD
virtual void run()
The starting point for the thread.
static void cleanup()
Cleans up the QThread system.
#define QT_END_NAMESPACE
This macro expands to.
T * data() const
Returns the value of the pointer referenced by this object.
~QThread()
Destroys the QThread.
void setStackSize(uint stackSize)
Sets the maximum stack size for the thread to stackSize.
uint stackSize() const
Returns the maximum stack size for the thread (if set with setStackSize()); otherwise returns zero...
QThread(QObject *parent=0)
Constructs a new QThread to manage a new thread.
T * take()
Returns the value of the pointer referenced by this object.
void finished()
This signal is emitted when the thread has finished executing.
void unlock()
Unlocks this mutex locker.
static QThread * theMainThread
bool ref()
Atomically increments the value of this QAtomicInt.
static void clearCurrentThreadData()
The QObject class is the base class of all Qt objects.
Priority
This enum type indicates how the operating system should schedule newly created threads.
void quit()
Tells the thread's event loop to exit with return code 0 (success).
QAdoptedThread(QThreadData *data=0)
Priority priority() const
Returns the priority for a running thread.
void relock()
Relocks an unlocked mutex locker.
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QEventLoop class provides a means of entering and leaving an event loop.
QThreadData(int initialRefCount=1)
const T & at(int i) const
Returns the item at index position i in the list.
bool deref()
Atomically decrements the value of this QAtomicInt.
static QMutexPool * instance()
Returns the global QMutexPool instance.
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
QPostEventList postEventList
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Q_CORE_EXPORT QMutexPool * qt_global_mutexpool
QThreadPrivate(QThreadData *d=0)
Q_CORE_EXPORT void qFatal(const char *,...)
#define Q_ASSERT_X(cond, where, what)
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void terminated()
This signal is emitted when the thread is terminated.
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
QObject * parent() const
Returns a pointer to the parent object.
bool wait(unsigned long time=ULONG_MAX)
Blocks the thread until either of these conditions is met:
int exec()
Enters the event loop and waits until exit() is called, returning the value that was passed to exit()...
int size() const
Returns the number of items in the list.
static QThreadData * current()
static QThread * createThreadForAdoption()
bool isFinished() const
Returns true if the thread is finished; otherwise returns false.
The QThread class provides a platform-independent way to manage threads.
bool isRunning() const
Returns true if the thread is running; otherwise returns false.
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void exit(int retcode=0)
Tells the thread's event loop to exit with a return code.
void qt_create_tls()
Initializes the QThread system.
void run()
The starting point for the thread.