[Qt-interest] Multithreading - yield function
Patric
userqt at gmail.com
Mon Aug 31 21:46:20 CEST 2009
I will consider that, I don't have much experience with threads.
One thing I don't understand, why there would be a function like yield that
don't always work. What is the reason such a function to exist if it's not
good to use it.
Sorry if my questions are obvious or something like that. :)
Regards,
Patric
----- Original Message -----
From: "Andreas Pakulat" <apaku at gmx.de>
To: <qt-interest at trolltech.com>
Sent: Monday, August 31, 2009 9:42 PM
Subject: Re: [Qt-interest] Multithreading - yield function
> On 31.08.09 21:09:12, Patric wrote:
>> 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.
>
> Then either don't use queued connections but direct ones, or use the
> usual thread-communication mechanisms to make your thread stop at that
> point until the receiving thread is done with the slot. You could do
> this for example with a QWaitCondition.
>
> Andreas
>
> --
> You will become rich and famous unless you don't.
> _______________________________________________
> 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