Thread Support in Qt
Qt 提供独立于平台的线程类, 线程安全的事件发布方式, 及跨线程的信号槽连接的形式. 这使得开发可移植的多线程 Qt 应用程序和利用多处理器机器变得容易. 多线程编程也是一种有用的范例, 可以在不阻塞应用程序用户界面的情况下执行耗时的操作.
Qt 的早期版本提供了在没有线程支持的情况下构建库的选项. 从 Qt 4.0 开始, 线程始终处于启用状态.
主题:
下列文章假设读者具有有关多线程应用程序的基本知识.
- The Threading Classes
- Multithreading Technologies in Qt
- Synchronizing Threads
- Reentrancy and Thread-Safety
- Threads and QObjects
- Thread-Support in Qt Modules
The Threading Classes
下列类与线程相关.
High-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives | |
Platform-independent atomic operations on integers | |
Template class that provides platform-independent atomic operations on pointers | |
Represents the result of an asynchronous computation | |
Convenience class that simplifies QFuture synchronization | |
Allows monitoring a QFuture using signals and slots | |
Access serialization between threads | |
Convenience class that simplifies locking and unlocking mutexes | |
Convenience class that simplifies locking and unlocking read-write locks for read access | |
Read-write locking | |
Convenience class that simplifies locking and unlocking read-write locks for write access | |
The base class for all runnable objects | |
General counting semaphore | |
Platform-independent way to manage threads | |
Manages a collection of QThreads | |
Per-thread data storage | |
Condition variable for synchronizing threads |
注意: Qt 的线程类是使用本地平台的线程 API 实现的; 如., Win32 和 pthreads. 因此, 它们可以与相同平台 API 的线程一起使用.