[Qt-interest] Is it "bad" to call a blocking function of Thread B directly in Thread A?

Sven Grunewaldt strayer at olle-orks.org
Wed Oct 6 13:33:32 CEST 2010


Hi,

let's assume I have two classes, Producer and Consumer. Both of these
classes run in their own QThread. Now I want to call a blocking function
of Producer within Consumer (via a pointer to the instance).

There is no possibility of two Consumers trying to access the same
Producer at the same time and stuff like that. Only one Consumer and one
Producer.

I tried this with a simple testcase and it seems to work:
http://pastebin.ca/1955512 (Sorry for the Windows.h and Sleep() )

I think I could achieve the same thing with Signals/Slots and
QWaitCondition, but since there are only two instances and no real
concurrence this looks way to complicated.

Is this in some way dangerous, very bad practice, not portable, etc.?



More information about the Qt-interest-old mailing list