QObject的Thread Affinity翻译
来源:互联网 发布:sql select as语句 编辑:程序博客网 时间:2024/05/18 04:01
Thread Affinity
线程亲和
A QObject instance is said to have a thread affinity, or that it lives in a certain thread. When aQObject receives aqueued signal or aposted event, the slot or event handler will run in the thread that the object lives in.
QObject实例可以说是线程亲和的,它生存在某个线程中。当QObject收到一个队列信号(queue signal)或一个发布事件(posted event),槽或事件处理将在对象所生存的线程中运行。
Note:If a QObject has no thread affinity (that is, ifthread() returns zero), or if it lives in a thread that has no running event loop, then it cannot receive queued signals or posted events.
注意:如果QObject没有线程亲和(就是说,如果thread()返回0),或者如果其生存在一个没有运行事件循环的线程中,则其不能收到队列信号或发布事件。
By default, a QObject lives in the thread in which it is created. An object's thread affinity can be queried usingthread() and changed usingmoveToThread().
默认下,QObject生存在创建其的线程中。一个对象的线程亲和可以使用thread()查询,可以用moveToThread()改变。
All QObjects must live in the same thread as their parent. Consequently:
所有的QObject必须和它们的父亲生存在相同的线程。因此:
- setParent() will fail if the two QObjects involved live in different threads.
- 如果setParent()相连的两个QObject不在一个线程中,则会失败。
- When a QObject is moved to another thread, all its children will be automatically moved too.
- 当一个QObject被移到另一个线程,其所有的孩子都会被自动的移入。
- moveToThread() will fail if theQObject has a parent.
- 如果QObject有父母,则moveToThread()会失败。
- If QObjects are created within QThread::run(), they cannot become children of theQThread object because theQThread does not live in the thread that callsQThread::run().
- 如果QObject在QThread::run()中创建,则其不能成为QThread对象的孩子,因为QThread并不在它调用的线程中。
Note:A QObject's member variablesdo not automatically become its children. The parent-child relationship must be set by either passing a pointer to the child'sconstructor, or by callingsetParent(). Without this step, the object's member variables will remain in the old thread whenmoveToThread() is called.
注意:QObject的成员变量并不会自动成为其孩子。父子关系必须通过给孩子的构造器传指针或调用setParent()设置。如果没有这个步骤,在调用moveToThread()后,对象的成员变量将会保持在之前的线程中。
- QObject的Thread Affinity翻译
- QObject 之 Thread Affinity
- QObject 之 Thread Affinity
- QObject 之 Thread Affinity
- QObject 之 Thread依附性
- Qt文档翻译之-QObject
- Qt Tcp多线程下QObject:Can not create children that is in different thread 的解决方法
- 一个疑惑的问题:QObject::killTimer: Timers cannot be stopped from another thread
- [原创]WCF后续之旅(11): 关于并发、回调的线程关联性(Thread Affinity)
- paip. 'QObject::QObject(const QObject&)' is private问题的解决.
- QT4 thread和QObject关系详解
- QT4 thread和QObject关系详解
- 翻译Thread
- QObject 的线程关联性
- QObject宏的解析
- QObject
- QObject
- [原创]WCF后续之旅(12): 线程关联性(Thread Affinity)对WCF并发访问的影响
- Mysql简介
- Python实现对Android截图
- L
- Lua入门
- [Python]打印实参名
- QObject的Thread Affinity翻译
- Find them, Catch them
- 广播实时监听网络状态
- CSU 1785 又一道简单题
- CSS样式设置语法全解,样式优先级、值和单位、字体、文本、块级元素,行内元素,替换元素、非替换元素、display、float、position、table、li、光标、边距边框、轮廓、颜色背景
- spring(七)AOP,事务的隔离级别、传播特性、配置
- matlab double 转 integer 方法
- 交叉编译器的命名规则
- 【NOIP模拟8.8】