Qt 4.8
|
The QThread class provides a platform-independent way to manage threads. More...
#include <qthread.h>
Public Types | |
enum | Priority { IdlePriority, LowestPriority, LowPriority, NormalPriority, HighPriority, HighestPriority, TimeCriticalPriority, InheritPriority } |
This enum type indicates how the operating system should schedule newly created threads. More... | |
Public Slots | |
void | quit () |
Tells the thread's event loop to exit with return code 0 (success). More... | |
void | start (Priority=InheritPriority) |
Begins execution of the thread by calling run(). More... | |
void | terminate () |
Terminates the execution of the thread. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | finished () |
This signal is emitted when the thread has finished executing. More... | |
void | started () |
This signal is emitted when the thread starts executing. More... | |
void | terminated () |
This signal is emitted when the thread is terminated. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
void | exit (int retcode=0) |
Tells the thread's event loop to exit with a return code. More... | |
bool | isFinished () const |
Returns true if the thread is finished; otherwise returns false. More... | |
bool | isRunning () const |
Returns true if the thread is running; otherwise returns false. More... | |
Priority | priority () const |
Returns the priority for a running thread. More... | |
QThread (QObject *parent=0) | |
Constructs a new QThread to manage a new thread. More... | |
void | setPriority (Priority priority) |
This function sets the priority for a running thread. More... | |
void | setStackSize (uint stackSize) |
Sets the maximum stack size for the thread to stackSize. More... | |
uint | stackSize () const |
Returns the maximum stack size for the thread (if set with setStackSize()); otherwise returns zero. More... | |
bool | wait (unsigned long time=ULONG_MAX) |
Blocks the thread until either of these conditions is met: More... | |
~QThread () | |
Destroys the QThread. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Static Public Functions | |
static QThread * | currentThread () |
Returns a pointer to a QThread which manages the currently executing thread. More... | |
static Qt::HANDLE | currentThreadId () |
Returns the thread handle of the currently executing thread. More... | |
static int | idealThreadCount () |
Returns the ideal number of threads that can be run on the system. More... | |
static void | yieldCurrentThread () |
Yields execution of the current thread to another runnable thread, if any. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Protected Functions | |
int | exec () |
Enters the event loop and waits until exit() is called, returning the value that was passed to exit(). More... | |
QThread (QThreadPrivate &dd, QObject *parent=0) | |
virtual void | run () |
The starting point for the thread. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Static Protected Functions | |
static void | msleep (unsigned long) |
Forces the current thread to sleep for msecs milliseconds. More... | |
static void | setTerminationEnabled (bool enabled=true) |
Enables or disables termination of the current thread based on the enabled parameter. More... | |
static void | sleep (unsigned long) |
Forces the current thread to sleep for secs seconds. More... | |
static void | usleep (unsigned long) |
Forces the current thread to sleep for usecs microseconds. More... | |
Static Private Functions | |
static void | cleanup () |
Cleans up the QThread system. More... | |
static void | initialize () |
Friends | |
class | QCoreApplication |
class | QThreadData |
Additional Inherited Members | |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QThread class provides a platform-independent way to manage threads.
A QThread object manages one thread of control within the program. QThreads begin executing in run(). By default, run() starts the event loop by calling exec() and runs a Qt event loop inside the thread.
You can use worker objects by moving them to the thread using QObject::moveToThread().
The code inside the Worker's slot would then execute in a separate thread. However, you are free to connect the Worker's slots to any signal, from any object, in any thread. It is safe to connect signals and slots across different threads, thanks to a mechanism called queued connections.
Another way to make code run in a separate thread, is to subclass QThread and reimplement run(). For example:
In that example, the thread will exit after the run function has returned. There will not be any event loop running in the thread unless you call exec().
It is important to remember that a QThread instance lives in the old thread that instantiated it, not in the new thread that calls run(). This means that all of QThread's queued slots will execute in the old thread. Thus, a developer who wishes to invoke slots in the new thread must use the worker-object approach; new slots should not be implemented directly into a subclassed QThread.
When subclassing QThread, keep in mind that the constructor executes in the old thread while run() executes in the new thread. If a member variable is accessed from both functions, then the variable is accessed from two different threads. Check that it is safe to do so.
QThread will notifiy you via a signal when the thread is started(), finished(), and terminated(), or you can use isFinished() and isRunning() to query the state of the thread.
You can stop the thread by calling exit() or quit(). In extreme cases, you may want to forcibly terminate() an executing thread. However, doing so is dangerous and discouraged. Please read the documentation for terminate() and setTerminationEnabled() for detailed information.
From Qt 4.8 onwards, it is possible to deallocate objects that live in a thread that has just ended, by connecting the finished() signal to QObject::deleteLater().
Use wait() to block the calling thread, until the other thread has finished execution (or until a specified time has passed).
The static functions currentThreadId() and currentThread() return identifiers for the currently executing thread. The former returns a platform specific ID for the thread; the latter returns a QThread pointer.
To choose the name that your thread will be given (as identified by the command ps -L
on Linux, for example), you can call setObjectName() before starting the thread. If you don't call setObjectName(), the name given to your thread will be the class name of the runtime type of your thread object (for example, "RenderThread"
in the case of the Mandelbrot Example, as that is the name of the QThread subclass). Note that this is currently not available with release builds on Windows.
QThread also provides static, platform independent sleep functions: sleep(), msleep(), and usleep() allow full second, millisecond, and microsecond resolution respectively.
enum QThread::Priority |
This enum type indicates how the operating system should schedule newly created threads.
Enumerator | |
---|---|
IdlePriority | |
LowestPriority | |
LowPriority | |
NormalPriority | |
HighPriority | |
HighestPriority | |
TimeCriticalPriority | |
InheritPriority |
Definition at line 70 of file qthread.h.
|
explicit |
Constructs a new QThread to manage a new thread.
The parent takes ownership of the QThread. The thread does not begin executing until start() is called.
Definition at line 433 of file qthread.cpp.
Referenced by priority().
QThread::~QThread | ( | ) |
Destroys the QThread.
Note that deleting a QThread object will not stop the execution of the thread it manages. Deleting a running QThread (i.e. isFinished() returns false) will probably result in a program crash. Wait for the finished() signal before deleting the QThread.
Definition at line 460 of file qthread.cpp.
|
protected |
Definition at line 443 of file qthread.cpp.
|
staticprivate |
Cleans up the QThread system.
Definition at line 661 of file qthread.cpp.
Referenced by QCoreApplication::~QCoreApplication().
|
static |
Returns a pointer to a QThread which manages the currently executing thread.
Definition at line 419 of file qthread.cpp.
Referenced by QDBusConnectionPrivate::activateCall(), QEventDispatcherUNIX::activateTimers(), QTextHtmlParserNode::applyBackgroundImage(), QDBusAbstractInterface::callWithArgumentList(), QCoreApplicationPrivate::checkReceiverThread(), connManager(), QDBusConnectionPrivate::deleteYourself(), QDBusConnectionPrivate::deliverCall(), QNetworkSession::disconnectNotify(), QTextImageHandler::drawObject(), elapsed(), QThreadStorageData::finish(), QDBusConnectionPrivate::handleObjectCall(), QEventDispatcherQPAPrivate::hasIntegration(), huntAndEmit(), QGLSignalProxy::instance(), QTextImageHandler::intrinsicSize(), QMetaMethod::invoke(), QRawFontPrivate::isValid(), jump(), QRawFont::loadFromData(), QTextDocument::loadResource(), QFontDatabase::loadXlfd(), QHostInfo::lookupHost(), QBBScreen::newWindowCreated(), QApplication::notify(), operator<<(), priority(), QStateMachinePrivate::processEvents(), QCoreApplicationPrivate::QCoreApplicationPrivate(), qDBusAddTimeout(), qDBusAddWatch(), qDBusIntrospectObject(), qDBusPropertyGet(), qDBusPropertyGetAll(), qDBusPropertySet(), qDBusRemoveTimeout(), qDBusRemoveWatch(), qDBusToggleWatch(), QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(), QFontEngineX11FT::QFontEngineX11FT(), QGLEngineSharedShaders::QGLEngineSharedShaders(), qt_grab_cursor(), qt_painter_thread_test(), qt_pixmap_thread_test(), qt_set_current_thread_to_main_thread(), qt_win_display_dc(), QEventDispatcherWin32::registerEventNotifier(), QEventDispatcherGlib::registerSocketNotifier(), QEventDispatcherWin32::registerSocketNotifier(), QEventDispatcherMac::registerSocketNotifier(), QEventDispatcherUNIX::registerSocketNotifier(), QEventDispatcherGlib::registerTimer(), QEventDispatcherWin32::registerTimer(), QEventDispatcherMac::registerTimer(), QEventDispatcherUNIX::registerTimer(), QDBusAdaptorConnector::relaySlot(), QSocks5BindStore::retrieve(), QEventDispatcherQPAPrivate::runEventLoopIntegration(), QPlatformGLContextPrivate::setCurrentContext(), QEventDispatcherUNIX::setSocketNotifierPending(), QMacPrintEnginePrivate::shouldSuppressStatus(), QEventDispatcherWin32::unregisterEventNotifier(), QEventDispatcherGlib::unregisterSocketNotifier(), QEventDispatcherWin32::unregisterSocketNotifier(), QEventDispatcherMac::unregisterSocketNotifier(), QEventDispatcherUNIX::unregisterSocketNotifier(), QEventDispatcherGlib::unregisterTimer(), QEventDispatcherWin32::unregisterTimer(), QEventDispatcherMac::unregisterTimer(), QEventDispatcherUNIX::unregisterTimer(), QEventDispatcherGlib::unregisterTimers(), QEventDispatcherWin32::unregisterTimers(), QEventDispatcherMac::unregisterTimers(), QEventDispatcherUNIX::unregisterTimers(), QBBScreen::windowClosed(), QDBusConnectionPrivate::~QDBusConnectionPrivate(), and QGLEngineSharedShaders::~QGLEngineSharedShaders().
|
static |
Returns the thread handle of the currently executing thread.
Definition at line 400 of file qthread_unix.cpp.
Referenced by QHttpThreadDelegate::abortRequest(), QMetaObject::activate(), QGLContext::choosePixelFormat(), QThreadPrivate::finish(), QHttpThreadDelegate::finishedSlot(), QHttpThreadDelegate::finishedWithErrorSlot(), QHttpThreadDelegate::headerChangedSlot(), id_function(), QMutex::lock(), QReadWriteLock::lockForRead(), QReadWriteLock::lockForWrite(), QCoreApplicationPrivate::QCoreApplicationPrivate(), QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate(), QHttpThreadDelegate::startRequest(), QHttpThreadDelegate::startRequestSynchronously(), QHttpThreadDelegate::synchronousAuthenticationRequiredSlot(), QHttpThreadDelegate::synchronousFinishedSlot(), QHttpThreadDelegate::synchronousFinishedWithErrorSlot(), QHttpThreadDelegate::synchronousHeaderChangedSlot(), QHttpThreadDelegate::synchronousProxyAuthenticationRequiredSlot(), QMutex::tryLock(), QReadWriteLock::tryLockForRead(), QReadWriteLock::tryLockForWrite(), and QReadWriteLock::unlock().
|
protected |
Enters the event loop and waits until exit() is called, returning the value that was passed to exit().
The value returned is 0 if exit() is called via quit().
This function is meant to be called from within run(). It is necessary to call this function to start event handling.
Definition at line 551 of file qthread.cpp.
Referenced by QDeclarativeXmlQueryEngine::run().
void QThread::exit | ( | int | returnCode = 0 | ) |
Tells the thread's event loop to exit with a return code.
After calling this function, the thread leaves the event loop and returns from the call to QEventLoop::exec(). The QEventLoop::exec() function returns returnCode.
By convention, a returnCode of 0 means success, any non-zero value indicates an error.
Note that unlike the C library function of the same name, this function does return to the caller – it is event processing that stops.
No QEventLoops will be started anymore in this thread until QThread::exec() has been called again. If the eventloop in QThread::exec() is not running then the next call to QThread::exec() will also return immediately.
Definition at line 592 of file qthread.cpp.
Referenced by quit(), QIntMouseListenThread::run(), and QIntKeyboardListenThread::run().
|
signal |
This signal is emitted when the thread has finished executing.
Use isFinished() instead.
Referenced by QThreadData::current(), QThreadPrivate::finish(), and QAdoptedThread::QAdoptedThread().
|
static |
Returns the ideal number of threads that can be run on the system.
This is done querying the number of processor cores, both real and logical, in the system. This function returns -1 if the number of processor cores could not be detected.
Definition at line 411 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish(), and QMutex::lockInternal().
|
staticprivate |
Definition at line 643 of file qthread.cpp.
Referenced by QCoreApplication::init().
bool QThread::isFinished | ( | ) | const |
Returns true if the thread is finished; otherwise returns false.
Definition at line 482 of file qthread.cpp.
bool QThread::isRunning | ( | ) | const |
Returns true if the thread is running; otherwise returns false.
Definition at line 494 of file qthread.cpp.
Referenced by QKqueueFileSystemWatcherEngine::addPaths(), QWindowsPipeWriter::write(), and QDnotifySignalThread::~QDnotifySignalThread().
|
staticprotected |
Forces the current thread to sleep for msecs milliseconds.
Definition at line 509 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish(), and QWindowsPipeWriter::run().
QThread::Priority QThread::priority | ( | ) | const |
Returns the priority for a running thread.
If the thread is not running, this function returns InheritPriority
.
Definition at line 718 of file qthread.cpp.
Referenced by QThreadPrivate::start().
|
slot |
Tells the thread's event loop to exit with return code 0 (success).
Equivalent to calling QThread::exit(0).
This function does nothing if the thread does not have an event loop.
Definition at line 614 of file qthread.cpp.
Referenced by QNetworkAccessHttpBackend::postRequest(), QDeclarativePixmapReader::QDeclarativePixmapReader(), QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(), QDeclarativeXmlQueryEngine::QDeclarativeXmlQueryEngine(), QDnotifySignalThread::readFromDnotify(), QInotifyFileSystemWatcherEngine::stop(), QPollingFileSystemWatcherEngine::stop(), QDnotifySignalThread::~QDnotifySignalThread(), and QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate().
|
protectedvirtual |
The starting point for the thread.
After calling start(), the newly created thread calls this function. The default implementation simply calls exec().
You can reimplement this function to facilitate advanced thread management. Returning from this method will end the execution of the thread.
Reimplemented in QAdoptedThread, QNlaThread, QDeclarativeXmlQueryEngine, QProcessManager, QFileInfoGatherer, QIntKeyboardListenThread, QDeclarativePixmapReader, QWindowsFileSystemWatcherEngineThread, QWindowsPipeWriter, QScanThread, QPollingFileSystemWatcherEngine, QFSEventsFileSystemWatcherEngine, SelectWorker, QDnotifySignalThread, QIntMouseListenThread, QKqueueFileSystemWatcherEngine, QDeclarativeWorkerScriptEngine, QDnotifyFileSystemWatcherEngine, QInotifyFileSystemWatcherEngine, QThreadPoolThread, QDirectFbInput, and QBBScreenEventThread.
Definition at line 628 of file qthread.cpp.
Referenced by qt_adopted_thread_watcher_function(), and QThreadPrivate::start().
void QThread::setPriority | ( | Priority | priority | ) |
This function sets the priority for a running thread.
If the thread is not running, this function does nothing and returns immediately. Use start() to start a thread with a specific priority.
The priority argument can be any value in the QThread::Priority
enum except for InheritPriorty
.
The effect of the priority parameter is dependent on the operating system's scheduling policy. In particular, the priority will be ignored on systems that do not support thread priorities (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler for more details).
Definition at line 738 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish(), and QThreadPrivate::start().
void QThread::setStackSize | ( | uint | stackSize | ) |
Sets the maximum stack size for the thread to stackSize.
If stackSize is greater than zero, the maximum stack size is set to stackSize bytes, otherwise the maximum stack size is automatically determined by the operating system.
Definition at line 519 of file qthread.cpp.
|
staticprotected |
Enables or disables termination of the current thread based on the enabled parameter.
The thread must have been started by QThread.
When enabled is false, termination is disabled. Future calls to QThread::terminate() will return immediately without effect. Instead, the termination is deferred until termination is enabled.
When enabled is true, termination is enabled. Future calls to QThread::terminate() will terminate the thread normally. If termination has been deferred (i.e. QThread::terminate() was called with termination disabled), this function will terminate the calling thread immediately. Note that this function will not return in this case.
Definition at line 726 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish(), and qt_adopted_thread_watcher_function().
|
staticprotected |
Forces the current thread to sleep for secs seconds.
Definition at line 499 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish().
uint QThread::stackSize | ( | ) | const |
Returns the maximum stack size for the thread (if set with setStackSize()); otherwise returns zero.
Definition at line 534 of file qthread.cpp.
Referenced by setStackSize().
|
slot |
Begins execution of the thread by calling run().
The operating system will schedule the thread according to the priority parameter. If the thread is already running, this function does nothing.
The effect of the priority parameter is dependent on the operating system's scheduling policy. In particular, the priority will be ignored on systems that do not support thread priorities (such as on Linux, see http://linux.die.net/man/2/sched_setscheduler for more details).
Definition at line 583 of file qthread_unix.cpp.
Referenced by QInotifyFileSystemWatcherEngine::addPaths(), QKqueueFileSystemWatcherEngine::addPaths(), QWindowsFileSystemWatcherEngine::addPaths(), QPollingFileSystemWatcherEngine::addPaths(), QCoreWlanEngine::doRequestUpdate(), QThreadPrivate::finish(), QEventDispatcherQPAPrivate::hasIntegration(), QNetworkConfigurationManagerPrivate::initialize(), QDirectFbIntegration::initializeInput(), QProcessPrivate::pipeWriterBytesToWrite(), QNetworkAccessHttpBackend::postRequest(), QBBIntegration::QBBIntegration(), QDeclarativePixmapReader::QDeclarativePixmapReader(), QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(), QDeclarativeXmlQueryEngine::QDeclarativeXmlQueryEngine(), QFileInfoGatherer::QFileInfoGatherer(), QIntMouseHandler::QIntMouseHandler(), QNlaEngine::QNlaEngine(), QWSIntKbPrivate::QWSIntKbPrivate(), QProcessPrivate::startDetached(), QDnotifySignalThread::startNotify(), QProcessPrivate::startProcess(), QThreadPoolPrivate::startThread(), QThreadPoolPrivate::tryStart(), and QFSEventsFileSystemWatcherEngine::warmUpFSEvents().
|
signal |
This signal is emitted when the thread starts executing.
Referenced by qt_adopted_thread_watcher_function(), and QThreadPrivate::start().
|
slot |
Terminates the execution of the thread.
The thread may or may not be terminated immediately, depending on the operating system's scheduling policies. Listen for the terminated() signal, or use QThread::wait() after terminate(), to be sure.
When the thread is terminated, all threads waiting for the thread to finish will be woken up.
Termination can be explicitly enabled or disabled by calling QThread::setTerminationEnabled(). Calling this function while termination is disabled results in the termination being deferred, until termination is re-enabled. See the documentation of QThread::setTerminationEnabled() for more information.
Definition at line 689 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish(), and QWindowsPipeWriter::~QWindowsPipeWriter().
|
signal |
This signal is emitted when the thread is terminated.
Referenced by QThreadPrivate::finish().
|
staticprotected |
Forces the current thread to sleep for usecs microseconds.
Definition at line 521 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish().
bool QThread::wait | ( | unsigned long | time = ULONG_MAX | ) |
Blocks the thread until either of these conditions is met:
The thread associated with this QThread object has finished execution (i.
e. when it returns from run()). This function will return true if the thread has finished. It also returns true if the thread has not been started yet.
This provides similar functionality to the POSIX pthread_join()
function.
Definition at line 706 of file qthread_unix.cpp.
Referenced by QFSEventsFileSystemWatcherEngine::addPaths(), QNetworkConfigurationManagerPrivate::cleanup(), QThreadPrivate::finish(), QNetworkAccessHttpBackend::postRequest(), QScanThread::quit(), QKqueueFileSystemWatcherEngine::removePaths(), QWindowsFileSystemWatcherEngine::removePaths(), QFSEventsFileSystemWatcherEngine::removePaths(), QPollingFileSystemWatcherEngine::removePaths(), QThreadPoolPrivate::reset(), QBBScreenEventThread::shutdown(), QDeclarativePixmapReader::~QDeclarativePixmapReader(), QDeclarativeWorkerScriptEngine::~QDeclarativeWorkerScriptEngine(), QDeclarativeXmlQueryEngine::~QDeclarativeXmlQueryEngine(), QDirectFbIntegration::~QDirectFbIntegration(), QDnotifySignalThread::~QDnotifySignalThread(), QFileInfoGatherer::~QFileInfoGatherer(), QIntMousePrivate::~QIntMousePrivate(), QKqueueFileSystemWatcherEngine::~QKqueueFileSystemWatcherEngine(), QNlaThread::~QNlaThread(), ~QThread(), QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine(), QWindowsPipeWriter::~QWindowsPipeWriter(), and QWSIntKbPrivate::~QWSIntKbPrivate().
|
static |
Yields execution of the current thread to another runnable thread, if any.
Note that the operating system decides to which thread to switch.
Definition at line 474 of file qthread_unix.cpp.
Referenced by QThreadPrivate::finish(), and QMutex::lockInternal().
|
friend |
|
friend |