-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteLocker.h
More file actions
37 lines (29 loc) · 737 Bytes
/
Copy pathWriteLocker.h
File metadata and controls
37 lines (29 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef BaseLib_WriteLocker_h_IsIncluded
#define BaseLib_WriteLocker_h_IsIncluded
#include"BaseLib/ReadWriteLock.h"
#include"BaseLib/CommonDefines.h"
#include"BaseLib/Export.h"
namespace BaseLib
{
class DLL_STATE WriteLocker
{
public:
inline explicit WriteLocker(ReadWriteLock *mutex)
: mutex_(mutex)
{
if(mutex_ == NULL)
throw std::runtime_error("WriteLocker::WriteLocker(ReadWriteLocker*): Argument error! ReadWriteLocker* == NULL!");
mutex_->lockForWrite();
}
inline ~WriteLocker()
{
mutex_->unlock();
}
private:
ReadWriteLock *mutex_;
private:
WriteLocker(const WriteLocker &) { }
WriteLocker& operator=(const WriteLocker&) { return *this; }
};
}
#endif