[Qt-interest] Signal delivery order?
Jason H
scorp1us at yahoo.com
Wed Jul 14 17:48:54 CEST 2010
If you're on the same thread and they are directly connected, then they will be
executed in order as local function calls.
If they are queued, the statement does not apply.
If they are across threads (which have to be queued) then the statement does not
apply.
In short, I would not rely on any signal/slot call order. I would use a unifying
slot (wrapper) that would execute the functions in the correct order. slot
A::suff(){ if (iNeedToX) x(); if (iNeedToY) y();...}
________________________________
From: Atlant Schmidt <aschmidt at dekaresearch.com>
To: "qt-interest at trolltech.com" <qt-interest at trolltech.com>
Sent: Wed, July 14, 2010 11:20:06 AM
Subject: [Qt-interest] Signal delivery order?
Folks:
I’m trying to understand the order in which signals are delivered to slots.
When I look at:
http://doc.trolltech.com/4.6.2/signalsandslots.html
It first says:
If several slots are connected to one signal, the slots will be executed
one after the other, in the order they have been connected, when the
signal is emitted.
But later, it seems to take back that promise by saying:
If on the other hand you want to call two different error functions when
the number overflows, simply connect the signal to two different slots.
Qt will call both (in arbitrary order).
Depending on the implementation details, I could believe that, within a single
thread,
either statement is true (that slots are handed the signal in the order in
which they
were originally connected or that slots are handed the signals in an arbitrary
order);
clearly, the second statement subsumes the first and it’s easier for the
trolls if it’s
the latter. It’s also safer for me if *I BELIEVE* it’s the latter, even if
it’s sometimes
the former, but shouldn’t the documentation be self-consistent? Does anyone
know
which statement (“connection order” vs. “arbitrary order”) is more true? And
can
you correct the documentation? ;-)
Meanwhile, I also wonder about the delivery order when multiple signals are
emitted. Can we take it on faith that if a single thread emits the signals A,
B,
and C in that order, they will be delivered to a single slot in a single
thread in
the same order? How about if they are delivered to different (multiple) slots
in the same thread? Still A, B, then C, no matter which slot they’re
targetting?
Note: I understand that most of the ordering promises won’t hold any time
signals are delivered to different threads; one doesn’t know when the
individual
threads will actually be “runnable” so that they can receive the signals at
their slots.
But I would still expect that multiple signals emitted from one thread and
targeting
a single thread will be delivered to that thread in the order in which they
were
originally emitted.
Atlant
________________________________
This e-mail and the information, including any attachments, it contains are
intended to be a confidential communication only to the person or entity to whom
it is addressed and may contain information that is privileged. If the reader
of this message is not the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please immediately
notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100714/225fcd62/attachment.html
More information about the Qt-interest-old
mailing list