-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslim_read_write_lock.cxx
40 lines (32 loc) · 1.12 KB
/
slim_read_write_lock.cxx
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
38
39
40
#include "slim_read_write_lock.h"
#include "win32_helper.h"
#include <algorithm>
slim_read_write_lock::slim_read_write_lock() {
InitializeSRWLock(& this->_lock);
}
slim_read_write_lock::~slim_read_write_lock() {
}
void slim_read_write_lock::acquire_read_lock() throw() {
AcquireSRWLockShared(&this->_lock);
}
void slim_read_write_lock::release_read_lock() throw() {
ReleaseSRWLockShared(&this->_lock);
}
void slim_read_write_lock::acquire_write_lock() throw() {
AcquireSRWLockExclusive(&this->_lock);
}
void slim_read_write_lock::release_write_lock() throw() {
ReleaseSRWLockExclusive(&this->_lock);
}
std::string get_executable_dir(){
char path[MAX_PATH];
if(! GetModuleFileNameA(NULL, path, MAX_PATH)){
return std::string("c:\\");
}
std::string exe_path(path);
std::string::const_reverse_iterator last_slash_pos = std::find(exe_path.rbegin(), exe_path.rend(), '\\');
if(last_slash_pos == exe_path.rend()){
return std::string("c:\\");
}
return std::string(exe_path.begin(), std::string::const_iterator(last_slash_pos.base()));
}