Diffstat (limited to 'qmake/include/private/qlock_p.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/include/private/qlock_p.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/qmake/include/private/qlock_p.h b/qmake/include/private/qlock_p.h new file mode 100644 index 0000000..5c261aa --- a/dev/null +++ b/qmake/include/private/qlock_p.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of QLock class. This manages interprocess locking | ||
5 | ** | ||
6 | ** Created : 20000406 | ||
7 | ** | ||
8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the kernel module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed and/or modified under the terms of the | ||
13 | ** GNU General Public License version 2 as published by the Free Software | ||
14 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
15 | ** packaging of this file. | ||
16 | ** | ||
17 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | ||
18 | ** licenses for Qt/Embedded may use this file in accordance with the | ||
19 | ** Qt Embedded Commercial License Agreement provided with the Software. | ||
20 | ** | ||
21 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
22 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
23 | ** | ||
24 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
25 | ** information about Qt Commercial License Agreements. | ||
26 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
27 | ** | ||
28 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
29 | ** not clear to you. | ||
30 | ** | ||
31 | **********************************************************************/ | ||
32 | |||
33 | #ifndef QLOCK_P_H | ||
34 | #define QLOCK_P_H | ||
35 | |||
36 | // | ||
37 | // W A R N I N G | ||
38 | // ------------- | ||
39 | // | ||
40 | // This file is not part of the Qt API. This header file may | ||
41 | // change from version to version without notice, or even be | ||
42 | // removed. | ||
43 | // | ||
44 | // We mean it. | ||
45 | // | ||
46 | // | ||
47 | |||
48 | #ifndef QT_H | ||
49 | #include <qstring.h> | ||
50 | #endif // QT_H | ||
51 | |||
52 | class QLockData; | ||
53 | |||
54 | class QLock | ||
55 | { | ||
56 | public: | ||
57 | QLock( const QString &filename, char id, bool create = FALSE ); | ||
58 | ~QLock(); | ||
59 | |||
60 | enum Type { Read, Write }; | ||
61 | |||
62 | bool isValid() const; | ||
63 | void lock( Type type ); | ||
64 | void unlock(); | ||
65 | bool locked() const; | ||
66 | |||
67 | private: | ||
68 | Type type; | ||
69 | QLockData *data; | ||
70 | }; | ||
71 | |||
72 | |||
73 | // Nice class for ensuring the lock is released. | ||
74 | // Just create one on the stack and the lock is automatically released | ||
75 | // when QLockHolder is destructed. | ||
76 | class QLockHolder | ||
77 | { | ||
78 | public: | ||
79 | QLockHolder( QLock *l, QLock::Type type ) : qlock(l) { | ||
80 | qlock->lock( type ); | ||
81 | } | ||
82 | ~QLockHolder() { if ( locked() ) qlock->unlock(); } | ||
83 | |||
84 | void lock( QLock::Type type ) { qlock->lock( type ); } | ||
85 | void unlock() { qlock->unlock(); } | ||
86 | bool locked() const { return qlock->locked(); } | ||
87 | |||
88 | private: | ||
89 | QLock *qlock; | ||
90 | }; | ||
91 | |||
92 | #endif | ||
93 | |||