source: trunk/src/corelib/thread/qwaitcondition.qdoc

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 6.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29 \class QWaitCondition
30 \brief The QWaitCondition class provides a condition variable for
31 synchronizing threads.
32
33 \threadsafe
34
35 \ingroup thread
36
37 QWaitCondition allows a thread to tell other threads that some
38 sort of condition has been met. One or many threads can block
39 waiting for a QWaitCondition to set a condition with wakeOne() or
40 wakeAll(). Use wakeOne() to wake one randomly selected condition or
41 wakeAll() to wake them all.
42
43 For example, let's suppose that we have three tasks that should
44 be performed whenever the user presses a key. Each task could be
45 split into a thread, each of which would have a
46 \l{QThread::run()}{run()} body like this:
47
48 \snippet doc/src/snippets/code/src_corelib_thread_qwaitcondition_unix.cpp 0
49
50 Here, the \c keyPressed variable is a global variable of type
51 QWaitCondition.