]> git.lyx.org Git - lyx.git/blob - src/support/mutex.h
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / support / mutex.h
1 // -*- C++ -*-
2 /**
3  * \file mutex.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Peter Kümmel
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * A collection of string helper functions that works with string.
12  * Some of these would certainly benefit from a rewrite/optimization.
13  */
14
15 #ifndef MUTEX_H
16 #define MUTEX_H
17
18
19 namespace lyx {
20
21
22 class Mutex
23 {
24 public:
25         Mutex();
26         ~Mutex();
27         
28         /// Scope based locking:
29         /// Usage:
30         /// >>> unlocked
31         /// { 
32         ///     Mutex::Locker locker(a_Mutex_ptr);  
33         ///     >>> locked
34         /// }
35         /// >>> unlocked
36         class Locker
37         {
38         public:
39                 Locker(Mutex*);
40                 ~Locker();
41
42         private:
43                 Locker();
44                 Locker(const Locker& rhs);
45                 Locker& operator=(const Locker& rhs);
46                 Mutex* mutex_;
47         };
48         
49
50         // pseude-value semantic
51         // needed by GuiPrefs which makes a copy
52         Mutex(const Mutex&);
53         Mutex& operator=(const Mutex&);
54
55 private:
56         struct Private;
57         Private* d;
58 };
59
60
61 } // namespace lyx
62
63 #endif