[Qt-interest] adressing something to the mainWindow from adialog
John McClurkin
jwm at nei.nih.gov
Thu Apr 9 13:24:59 CEST 2009
First, the I believe the OP's case concerned a dialog that allowed human
interaction communicating changes that the human made. No human will
ever be able to flood the signal-slot mechanism in anything remotely
resembling a reasonable design.
But to the more general case you describe: Sometimes it is necessary to
violate OOP principles to achieve needed performance. Orthodoxy must
yield to practicality. I can imagine there will be use cases in which a
child must know about its parent and/or siblings. And when do you know
that you have encountered such a use case? From your knowledge and
experience as a professional software designer given the task at hand.
> 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.
>
> 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).
>
> But even if we had this mutex control and we still had to read and
> write the buffer via signals, and assuming that many other objects --
> not as many as a gazillion, but the speculation still holds -- may
> want to connect to the buffer, how's performance going to be affected?
>
> Wait, I realise that I'm making up a very special case and I
> appreciate the beauty of the formal approach you've suggested, but
> recently I found myself thinking about the dangers of a similar case:
> in such a case, wouldn't it be better to go for the parent linking its
> children to its internal variable protecting it via mutual exclusion?
> Or the overhead given by the mutex would still affect performance like
> the other case?
>
More information about the Qt-interest-old
mailing list