Do queued signal-slot connections and custom events arrive in order?
-
I have a GUI thread and a worker thread in my application and would like to communicate to the worker thread with both signal-slot connections and by supplying the worker thread with custom events.
If I emit a signal (A), then post a custom event (B), emit signal (A) again and post event (B) again, is it guaranteed that the order of execution in the worker thread is A -> B -> A -> B, or could it be possible that first all the signal-slots are handled and then all the events such that A -> A -> B -> B.
I need to take this into account into the design of the application, and did not find any documentation on this.
Thanks in advance! -
I have a GUI thread and a worker thread in my application and would like to communicate to the worker thread with both signal-slot connections and by supplying the worker thread with custom events.
If I emit a signal (A), then post a custom event (B), emit signal (A) again and post event (B) again, is it guaranteed that the order of execution in the worker thread is A -> B -> A -> B, or could it be possible that first all the signal-slots are handled and then all the events such that A -> A -> B -> B.
I need to take this into account into the design of the application, and did not find any documentation on this.
Thanks in advance!@aart said in Do queued signal-slot connections and custom events arrive in order?:
If I emit a signal (A), then post a custom event (B), emit signal (A) again and post event (B) again, is it guaranteed that the order of execution in the worker thread is A -> B -> A -> B, or could it be possible that first all the signal-slots are handled and then all the events such that A -> A -> B -> B.
It's guaranteed insofar as the current implementation is such that this is true, and importantly this can only be true if and only if you have one single thread that does the emissions and/or posting of events.
If you have two threads that feed the worker the order is undetermined.
If the current implementation changes the order is undefinable.So to conclude: Do not depend on event/slot execution order!
-
Hi,
I am not aware of such a guarantee between signal generated events and other events.
Can you explain a bit more your design which requires such a guarantee ?
-
I have a GUI thread and a worker thread in my application and would like to communicate to the worker thread with both signal-slot connections and by supplying the worker thread with custom events.
If I emit a signal (A), then post a custom event (B), emit signal (A) again and post event (B) again, is it guaranteed that the order of execution in the worker thread is A -> B -> A -> B, or could it be possible that first all the signal-slots are handled and then all the events such that A -> A -> B -> B.
I need to take this into account into the design of the application, and did not find any documentation on this.
Thanks in advance!@aart said in Do queued signal-slot connections and custom events arrive in order?:
If I emit a signal (A), then post a custom event (B), emit signal (A) again and post event (B) again, is it guaranteed that the order of execution in the worker thread is A -> B -> A -> B, or could it be possible that first all the signal-slots are handled and then all the events such that A -> A -> B -> B.
It's guaranteed insofar as the current implementation is such that this is true, and importantly this can only be true if and only if you have one single thread that does the emissions and/or posting of events.
If you have two threads that feed the worker the order is undetermined.
If the current implementation changes the order is undefinable.So to conclude: Do not depend on event/slot execution order!
-
@kshegunov said in Do queued signal-slot connections and custom events arrive in order?:
So to conclude: Do not depend on event/slot execution order!
What he said. Think of them as asynchronous, even if in the current implementation they are not.