[Qt-interest] Multithreading - yield function

Patric userqt at gmail.com
Mon Aug 31 20:09:12 CEST 2009


And how do you know that it didn't yield?

Yielding execution means allowing other threads to execute, while the 
calling
thread is suspended. Eventually, however, the calling thread will resume
working. So the "some other code" line *will* be executed, eventually.

Anyway, whether the yielding actually does anything depends on the operating
system and the scheduling priorities of the runnable threads. Like Thomas
said, if there are no threads waiting to be executed, there will be no
yielding. But even if there are other threads waiting, they may be of lower
priority, so yielding will do nothing. You may have to exhaust your 
timeslice
instead.

Finally, why do you need to yield? It's just a hint to the operating system.
It may decide to ignore it.


----------------------------------------------------------------------------------
Hi Thiago,
I'm using the debugger with multiple breakpoints and because of that I know 
if it's yielding or not. By default all threads priorities should be equal. 
I'm sure there is one thread that is waiting.

I need to yield it because my logic requires it. I'm using queued 
connections here and it's very important to know that the destination slot 
is emitted before the thread continues.
But if it's just a hint for the OS and it can decide to ignore it, that this 
is really not cool.

p.s.: sorry for the ignorance, but what is "timeslice" ?


Best regards,
Patric



----- Original Message ----- 
From: "Thiago Macieira" <thiago.macieira at trolltech.com>
To: <qt-interest at trolltech.com>
Sent: Monday, August 31, 2009 8:46 PM
Subject: Re: [Qt-interest] Multithreading - yield function


> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 




More information about the Qt-interest-old mailing list