diff options
author | Sze Howe Koh <szehowe.koh@gmail.com> | 2013-10-02 23:59:17 +0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-06 01:08:58 +0200 |
commit | dc6852ca63ab56eddb8a8843b0c383d51a4020a9 (patch) | |
tree | 123d3d1c7b6855cd7ff42669ee30345e2f923fed /src/corelib/doc/src/threads-basics.qdoc | |
parent | 370b64209256b1b5624a568e208d4e2bb6ce99c2 (diff) |
Doc: Expand on thread synchronization details
- Introduce the concept of "mutual exclusion"
- Rewrite/add explanations on how synchronization happens and how to
use these tools
- Remove similar content from the "Thread Basics" page
- Fix links to examples
Change-Id: Id008a8fc3f68bf242cae1704c5c8318149d908b4
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Diffstat (limited to 'src/corelib/doc/src/threads-basics.qdoc')
-rw-r--r-- | src/corelib/doc/src/threads-basics.qdoc | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/corelib/doc/src/threads-basics.qdoc b/src/corelib/doc/src/threads-basics.qdoc index 8b690c15ae..e511c10423 100644 --- a/src/corelib/doc/src/threads-basics.qdoc +++ b/src/corelib/doc/src/threads-basics.qdoc @@ -224,27 +224,11 @@ has terminated. \endlist - \section2 Using a Mutex to Protect the Integrity of Data - - A mutex is an object that has \l{QMutex::}{lock()} and \l{QMutex::}{unlock()} - methods and remembers if it is already locked. A mutex is designed to be - called from multiple threads. \l{QMutex::}{lock()} returns immediately if - the mutex is not locked. The next call from another thread will find the - mutex in a locked state and then \l{QMutex::}{lock()} will block the thread - until the other thread calls \l{QMutex::}{unlock()}. This functionality can - make sure that a code section will be executed by only one thread at a time. - - The following line sketches how a mutex can be used to make a method - thread-safe: - - \code - void Worker::work() - { - this->mutex.lock(); // first thread can pass, other threads will be blocked here - doWork(); - this->mutex.unlock(); - } - \endcode + \section2 Protecting the Integrity of Data + + When writing a multithread application, extra care must be taken to avoid + data corruption. See \l{Synchronizing Threads} for a discussion on how to + use threads safely. \section2 Dealing with Asynchronous Execution |