[Qt-interest] Queued/DirectConnections for signals across threads
Preet
preet.desai at gmail.com
Sun Dec 13 20:07:08 CET 2009
Hey all,
I have two threads, each with their own object. Both threads are running
exec() event loops so signals and slots will be handled by those two
threads. I have this one slot (slot Run) in one the objects (object A) that
has a while(someCondition) loop. This same object has another slot (slot
Stop) that will set 'someCondition' to false.
By default, any connections I make between the two objects will be of the
type QueuedConnection. My other object (object B) has signals to invoke the
Run and Stop slots. If I do something like:
ObjectB::someFunction()
{
someCondition = true;
emit signalRun; // queued connection
emit signalStop; // queued connection
std::cerr << "someFunction done" << std::endl;
}
I expect someFunction to emit two signals, then return immediately. I expect
object A's thread, if its not doing anything else, to be stuck in an
infinite while loop.
So if I do the following:
ObjectB::someFunction()
{
someCondition = true;
emit signalRun; // queued connection
emit signalStop; // direct connection
std::cerr << "someFunction done" << std::endl;
}
What is the resulting program flow?
Regards,
-Preet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091213/0f6b0bc4/attachment.html
More information about the Qt-interest-old
mailing list