Sleeping Wombat Common Library  0.50.0
swCommonLibrary
UniqueLock.h
Go to the documentation of this file.
1 #pragma once
2 
9 namespace sw
10 {
11 
13 template< typename MutexType >
15 {
16 private:
17 
18  MutexType& m_lock;
19 
20 public:
21 
22  WriterUniqueLock( MutexType& lock )
23  : m_lock( lock )
24  {
25  Lock();
26  }
27 
29  {
30  Unlock();
31  }
32 
34  void Lock()
35  {
36  m_lock.WriterLock();
37  }
38 
40  void Unlock()
41  {
42  m_lock.WriterUnlock();
43  }
44 
45 };
46 
48 template< typename MutexType >
50 {
51 private:
52 
53  MutexType& m_lock;
54 
55 public:
56 
57  ReaderUniqueLock( MutexType& lock )
58  : m_lock( lock )
59  {
60  Lock();
61  }
62 
64  {
65  Unlock();
66  }
67 
69  void Lock()
70  {
71  m_lock.ReaderLock();
72  }
73 
75  void Unlock()
76  {
77  m_lock.ReaderUnlock();
78  }
79 
80 };
81 
82 
83 
84 } // sw
85 
void Lock()
Locks writer lock.
Definition: UniqueLock.h:69
Definition: Exception.h:11
Equivalent of std::unique_lock class for ReaderWriterLock.
Definition: UniqueLock.h:14
void Lock()
Locks writer lock.
Definition: UniqueLock.h:34
void Unlock()
Unlocks writer lock.
Definition: UniqueLock.h:40
Equivalent of std::unique_lock class for ReaderWriterLock.
Definition: UniqueLock.h:49
void Unlock()
Unlocks writer lock.
Definition: UniqueLock.h:75