[Qt-interest] Confused by dev-net wiki article: inter-thread sig-slot connections
1+1=2
dbzhang800 at gmail.com
Mon Jun 20 15:28:54 CEST 2011
Hello everyone,
If we read Qt4.7.3's source code of QMetaObject::activate:
------------------- from Qt4.7.3 QMetaObject::activate ---------------
// determine if this connection should be sent immediately or
// put into the event queue
if ((c->connectionType == Qt::AutoConnection
&& (currentThreadData != sender->d_func()->threadData
|| receiver->d_func()->threadData !=
sender->d_func()->threadData))
|| (c->connectionType == Qt::QueuedConnection)) {
queued_activate(sender, signal_absolute_index, c, argv
? argv : empty_argv);
continue;
}
------------------------------------------------------------------------------
We can see that, both sender's thread and current thread are considered.
However, there is no sender's thead in Qt4.8's source code:
------------------from Qt4.8 QMetaObject::activate-----------------------
const bool receiverInSameThread = currentThreadId ==
receiver->d_func()->threadData->threadId;
// determine if this connection should be sent immediately or
// put into the event queue
if ((c->connectionType == Qt::AutoConnection &&
!receiverInSameThread)
|| (c->connectionType == Qt::QueuedConnection)) {
queued_activate(sender, signal_absolute_index, c, argv
? argv : empty_argv);
continue;
}
------------------------------------------------------------------------------
Debao.
On Fri, Jun 17, 2011 at 10:15 PM, Mandeep Sandhu
<mandeepsandhu.chd at gmail.com> wrote:
> Hi Frank! :)
>
>> I believe that this is incorrect. (And I don't recall Thiago saying it this
>> way.)
>
> You're probably right, as in Thiago might not have said the _exact_
> same thing (and meant something else)...though I did not mean to say
> this in any accusatory way! :)
>
>>
>> I hope I've got this right. Perhaps Thiago will straighten things out
>> if I've screwed something up here.
>
> I think you've got it right!
>
> My confusion mostly arose from the fact that I was assuming that
> "thread affinities" of sender/receiver objects were being compared
> (which were the same).
>
> But I guess instead it's comparing the "thread ID" of the execution
> context (probably what pthread_create() returns on unix platforms?)
> when the signal is emitted, with the receiver's thread ID.
>
> Thanks,
> -mandeep
>
>>
>>> Thanks,
>>> -mandeep
>>
>> Good luck.
>>
>>
>> K. Frank
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list