diff options
author | Corentin Jabot <corentinjabot@gmail.com> | 2013-01-20 13:24:30 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-05 08:20:18 +0200 |
commit | 5a02d30a78991240c3355d863f52b0d376ebf911 (patch) | |
tree | ad02a7281b44f452016bae6a31ec3a25f8905596 /src/corelib/thread/qthread_win.cpp | |
parent | 34195aa6cbc3bbe2b0bb38a86a3fb3ad76c40499 (diff) |
Add an advisory interruption mechanism to QThread.
To ease interruption of long running tasks, a new method
QThread::setInterruptionRequested() can be called.
The task can check QThread::isInterruptionRequested()
and act upon it by stopping itself.
These methods are designed to replace the use of a global variable
and other hacky ways to stop a task running in another thread.
Change-Id: I17622dd60d2262078210e7e4294ad6c53a6dc179
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qthread_win.cpp')
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index a0fac8eff2..d49a6a9a8e 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -377,6 +377,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway) d->running = false; d->finished = true; d->isInFinish = false; + d->interruptionRequested = false; if (!d->waiters) { CloseHandle(d->handle); @@ -446,6 +447,7 @@ void QThread::start(Priority priority) d->finished = false; d->exited = false; d->returnCode = 0; + d->interruptionRequested = false; /* NOTE: we create the thread in the suspended state, set the |