aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/readwritemutex.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unstable/readwritemutex.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/unstable/readwritemutex.h b/src/unstable/readwritemutex.h
index 8641e3f..eb159ca 100644
--- a/src/unstable/readwritemutex.h
+++ b/src/unstable/readwritemutex.h
@@ -69,6 +69,42 @@ namespace Bu
69 */ 69 */
70 void unlockWrite(); 70 void unlockWrite();
71 71
72 class ReadLocker
73 {
74 public:
75 ReadLocker( ReadWriteMutex &m ) :
76 m( m )
77 {
78 m.lockRead();
79 }
80
81 ~ReadLocker()
82 {
83 m.unlockRead();
84 }
85
86 private:
87 ReadWriteMutex &m;
88 };
89
90 class WriteLocker
91 {
92 public:
93 WriteLocker( ReadWriteMutex &m ) :
94 m( m )
95 {
96 m.lockWrite();
97 }
98
99 ~WriteLocker()
100 {
101 m.unlockWrite();
102 }
103
104 private:
105 ReadWriteMutex &m;
106 };
107
72 private: 108 private:
73 Bu::Mutex mRead; 109 Bu::Mutex mRead;
74 int iCounter; 110 int iCounter;