[Interest] Reset QThread requestedInterruption()
Thiago Macieira
thiago.macieira at intel.com
Sun Jul 27 16:27:19 CEST 2014
On Sunday 27 July 2014 13:22:03 Pérais Kévin wrote:
> So I don't see why this functionality should be only used in order to
> stop a thread running, and could be not be used to stop a JOB running in
> the thread (but not the thread itself).
The thing is that you can't reliably stop a job but not the thread by using
this functionality. You'd introduce a race condition.
Suppose you have two jobs queued for the same thread and you want to interrupt
the first. So you do thread->requestInterrupt().
However, say the job finished before the interruption came. In that case, it
will not reset the flag or it will race the resetting of the flag. In either
case, the flag remains set at the end of the first job.
So the second job starts and realises the flag is set, so it interrupts itself,
leading the third job to start.
Anyway, the point is that this method is in QThread and thus is talking about
interrupting the thread. If you want to interrupt jobs, add a flag to the job
class.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list