1. Who performs connect: sender or receiver ?
2. Who decides whether to ignore data: sender or receiver ?
1. Who performs connect: sender or receiver ?
2. Who decides whether to ignore data: sender or receiver ?
You are passing your QJsonObject instance by value: sendData( QJsonObject o ). In C++, this requires making a copy of the data. If you pass by reference instead: sendData( QJsonObject & o ) or sendData( const QJsonObject & o ) if the object will not be modified during the call, then you avoid copying.If I now copy the payload needlessly to many threads (all but one discard the message), I create an unnecessary overhead.
And as Lesiok asks, if you are in control of the connections, then why are you making connections to receivers who ignore the signal?
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
In general this is true, but not in the case of a QueuedConnection.
That mechanism requires that the signal arguments are stored in QVariant as the event being used for the delayed/cross-thread invocation uses that to store the arguments of the call.
However, if we look at QJsonOject's copy constructor we see that it uses reference counting instead of copying the data itself.
Which of course also means that none of the threads, including the main thread, should attempt any modification of the object as it is now shared data.
Cheers,
_
Bookmarks