[Qt-interest] Qt signaling smarts...

Gordon Schumacher gordon at rebit.com
Tue Nov 24 20:14:36 CET 2009


> KC Jones wrote:
>> I have nothing to add re: intra thread signaling, but I will point out
>> that signal/slot calls, especially queued, imply copying all of the
>> passed data.  So if you have a large volume of data you might need to
>> transmit it through some other mechanism (file, socket, etc.) and use
>> the signaling to marshal that resource between threads.
>>
>> But that's not really the advice what you were asking for...
>>     

Will Rutherdale (rutherw) wrote:
> A simpler way to avoid marshalling of big data between threads is to
> subclass from QEvent.  QCoreApplicatin::postEvent() will then put the
> event object into the event queue for the thread to which the object
> belongs.  You handle the incoming event by over-riding QObject::event().
>   

You have two choices, ultimately: copy the data, or protect it with
synchronization objects.  Stuffing it into a file or socket is a variant
of copying it.  Subclassing QEvent could be either one - you either
embed the data into the QEvent (which is a copy), or you include a
reference to it (which requires synchronization).

So the question is, which one is faster?  And I say again: until you've
profiled it, you're shooting in the dark ("programmers are notoriously
bad at predicting how their programs actually perform").



More information about the Qt-interest-old mailing list