PDA

View Full Version : Making Qt SOAP synchronous / efficiency of an empty while loop in a QThread ?



nooky59
18th February 2010, 11:34
Hi,

In my app, I used gSOAP for a long time, which make blocking calls, so it was perfect for my traditionnal QThread design.

I have noticed a problem, on most Linux platform (and Mac OS X I think), but not on Windows, where a float was truncated by the simple fact of instanciating a QApplication object... quite problematic...

So, I would like to use Qt Soap instead but this last one works in an asynchronous fashion and I don't want to reafactor all my app for the moment.

Can I have performance problems with an empy while loop like this, that wait for the answer of the SOAP server ?



http.submitRequest(request, "/");

while(!http.networkReply())
{

}

// Dealing with the result

Lesiok
18th February 2010, 14:18
Yes, an event loop is blocked. Add to loop one line :
QApplication::processEvents();

nooky59
18th February 2010, 14:57
Thanks for your answer, I did not thought about this method...

Even in a QThread this is problematic ?

Lesiok
18th February 2010, 15:01
Every thread has own event loop. All asynchronous processes are working with events. How http object can deal with events if You block event loop ?
By the way. It will be better to refactor Your code to properly work in event driven world :)