PDA

View Full Version : QTcpSocket makes my thread pause



ruben.rodrigues
7th June 2011, 15:17
Hi all!

I wrote a program that uses multiple threads and I am having some pauses in the middle of one of them that I can't understand.

One of the threads reads digital inputs from a machine to see if buttons are pressed and the other thread has a class that writes/reads tcp packages from a server that controls a laser.

These 2 threads are created by the same class but don't share anything. What happens is that when I call the line "tcpsocket->waitForReadyRead()" the thread that checks for the digital inputs just pauses and when the command is finished runs again.

Other than this problem the program runs perfectly but I realy need to read digital inputs while the program is waiting for an answer from the server.

Any tips?

Thanks!

wysota
7th June 2011, 15:30
That's what waitForReadyRead() does -- it waits (pauses) until a readyRead signal would be received.

ruben.rodrigues
7th June 2011, 15:32
That's what waitForReadyRead() does -- it waits (pauses) until a readyRead signal would be received.

But why does it pause a totally unrelated thread?

wysota
7th June 2011, 15:58
Maybe it is not as unrelated as you think. Check the thread affinity of the socket object. Make sure it is what you think it is.