我不确定 Qt 4.5 中信号/插槽机制的性质。发出信号时,是阻塞函数调用还是线程?说这个
emit GrabLatestData();
// proceed with latest data
在继续下一行之前,所有的信号/槽链都会被解析吗?
最佳答案
这取决于。来自 documentation :
When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call. When this happens, the signals and slots mechanism is totally independent of any GUI event loop. Execution of the code following the
emit
statement will occur once all slots have returned. The situation is slightly different when using queued connections; in such a case, the code following the emit keyword will continue immediately, and the slots will be executed later.
所以在正常情况下,它将是同步和阻塞的,而对于排队连接,它将是异步和非阻塞的。
关于Qt 4.5 - 发出信号是函数调用还是线程,它会阻塞吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1264887/