Re: [Interest] Terminating a QThread

2013-06-21 Thread Etienne Sandré-Chardonnal
Except in this particular case where: - The flag is set to false at the start of the thread - Set to true for stopping by the controlling(parent) thread (writen, never read) - Checked by the thread as a quit condition (read, never written) In that case, there is absolutely no possible race cond

Re: [Interest] Terminating a QThread

2013-06-21 Thread Thiago Macieira
On sábado, 22 de junho de 2013 12.41.10, Tony Rietwyk wrote: > But a bool value can be cached indefinitely, so make sure you declare the > flag as volatile! That's wrong and has been explained away several times. You need to declare it as atomic, not as volatile. -- Thiago Macieira - thiago.macie

Re: [Interest] Terminating a QThread

2013-06-21 Thread Tony Rietwyk
2013 9:01 PM Cc: interest@qt-project.org Subject: Re: [Interest] Terminating a QThread Sorry Mandeep, I didn't read your post first. Basically what I posted is similar. A mutex is a little bit overkill here, you could use an atomic variable if you want to be sure, but just a bool flag wi

Re: [Interest] Terminating a QThread

2013-06-21 Thread Etienne Sandré-Chardonnal
Hi, This was my case, but after a careful study of how the event loop and queued signal/slot connection works, I figured it out and everything works cleanly now. It's easy to have this issue, as if you ask the thread to quit via a signal/slot, you have to ensure that nothing is destroyed or blocke

Re: [Interest] Terminating a QThread

2013-06-21 Thread alexander golks
Am Fri, 21 Jun 2013 15:50:16 +0200 schrieb Etienne Sandré-Chardonnal : > Well, after a quick test, it seems that terminate is not working under > windows (at least, not working as expected by reading the manual). > just to put in my 2 windows cents: sometimes my threads even don't stop when i qu

Re: [Interest] Terminating a QThread

2013-06-21 Thread Etienne Sandré-Chardonnal
:* Etienne Sandré-Chardonnal > *À :* > *Cc :* "interest@qt-project.org" > *Envoyé le :* Vendredi 21 juin 2013 13h00 > *Objet :* Re: [Interest] Terminating a QThread > > Sorry Mandeep, I didn't read your post first. Basically what I posted is > similar. > >

Re: [Interest] Terminating a QThread

2013-06-21 Thread francois cellier
. I was just hoping that someone that knows well QThread would help me to understand. François De : André Somers À : interest@qt-project.org Envoyé le : Vendredi 21 juin 2013 14h12 Objet : Re: [Interest] Terminating a QThread Op 21-6-2013 10:06, francois

Re: [Interest] Terminating a QThread

2013-06-21 Thread André Somers
Op 21-6-2013 10:06, francois cellier schreef: Dear all, Even if I know that it can be dangerous to terminate a thread, I need to do it for my application. Are you really going to completely re-do the discussion you already had on the qt-project.org forums? André -- You like Qt? I am looking

Re: [Interest] Terminating a QThread

2013-06-21 Thread francois cellier
know why the terminate function does not terminate my thread if an eventloop is running. De : Etienne Sandré-Chardonnal À : Cc : "interest@qt-project.org" Envoyé le : Vendredi 21 juin 2013 13h00 Objet : Re: [Interest] Terminating a QThread Sor

Re: [Interest] Terminating a QThread

2013-06-21 Thread Etienne Sandré-Chardonnal
Sorry Mandeep, I didn't read your post first. Basically what I posted is similar. A mutex is a little bit overkill here, you could use an atomic variable if you want to be sure, but just a bool flag will be enough as it is always set atomically AFAIK 2013/6/21 Mandeep Sandhu > On Fri, Jun 21,

Re: [Interest] Terminating a QThread

2013-06-21 Thread Etienne Sandré-Chardonnal
The best is still not to terminate threads if not absolutely necessary. Even without an event loop, you can poll a flag that asks the thread to return from the run function. For instance: void RenderThread::run() { while(!stopRequested) { //Do some intensive calcul

Re: [Interest] Terminating a QThread

2013-06-21 Thread Mandeep Sandhu
On Fri, Jun 21, 2013 at 1:36 PM, francois cellier wrote: > Dear all, > > Even if I know that it can be dangerous to terminate a thread, I need to > do it for my application. > The function that run into the thread is like a long linear sequence of > code that has not been designed in a signal/slot

[Interest] Terminating a QThread

2013-06-21 Thread francois cellier
Dear all, Even if I know that it can be dangerous to terminate a thread, I need to do it for my application. The function that run into the thread is like a long linear sequence of code that has not been designed in a signal/slot way. Moreover, in my thread, I need an eventloop as I use in it s