[Qt-interest] adressing something to the mainWindow from adialog
Arnold Krille
arnold at arnoldarts.de
Wed Apr 8 19:59:37 CEST 2009
Hi,
On Wednesday 08 April 2009 19:45:40 Andrea Franceschini wrote:
> Thanks for your thorough explanation, John. I've never really thought
> of using signals and slots this way. I am now a bit concerned about
> performance, anyway. Even if the docs imply that on fairly recent
> hardware you can emit like a gazillion signals per seconds, given one
> receiver connected, as it shall be obvious, it doesn't really seem to
> scale very well, as in slightly-more-than-half a gazillion signals per
> seconds when another receiver is connected. This, of course, assuming
> -- well, I am assuming it -- the receivers are doing plenty of nothing
> in their slots.
Actually you can send (and receive) a _lot_ of events per second in Qt. And
signals/slots become events when they span thread-boundaries. I know from my
software that sending >10000 events per second for as long as several days
works without breakage or memory faults.
The only thing you have to watch is multiple threads accessing the same data.
Which in the case of small elements where the sender is not interested in the
changes done by the receivers can be send by reference. If the data-structur
is to big for that, you copy an object that only contains a pointer to the
real data structure and does ref-counting to delete the real structure when
its not used anymore. Of course the ref-counting has to be atomic, but
QAtomic(Int?) does a good job at that...
> Now, what if I had two objects that needed to continuously monitor the
> same value -- namely a value which is a property of one of the two and
> that each of the two objects are entitled to both read and write? This
> would be the academic case of two communicating endpoints over the
> same channel which is a member of one of the two objects. Such can be
> solved, when appropriate, with mutexes (here for "appropriate" I'm
> implying that the communication channel is strictly under control of
> the system such as a shared memory buffer on the same machine that
> runs the two endpoints).
Qt signals only work in the same app, so its by definition the same machine and
shared memory. :-)
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090408/d869b854/attachment.bin
More information about the Qt-interest-old
mailing list