blob: 0da7bf4bd50429eced36a8ffaea6cfd8e5d34dbb (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#if defined(WINDOWS_ENABLED)
#include "os/memory.h"
#include "rw_lock_windows.h"
#include "error_macros.h"
#include <stdio.h>
void RWLockWindows::read_lock() {
AcquireSRWLockShared(&lock);
}
void RWLockWindows::read_unlock() {
ReleaseSRWLockShared(&lock);
}
Error RWLockWindows::read_try_lock() {
if (TryAcquireSRWLockShared(&lock)==0) {
return ERR_BUSY;
} else {
return OK;
}
}
void RWLockWindows::write_lock() {
AcquireSRWLockExclusive(&lock);
}
void RWLockWindows::write_unlock() {
ReleaseSRWLockExclusive(&lock);
}
Error RWLockWindows::write_try_lock() {
if (TryAcquireSRWLockExclusive(&lock)==0) {
return ERR_BUSY;
} else {
return OK;
}
}
RWLock *RWLockWindows::create_func_windows() {
return memnew( RWLockWindows );
}
void RWLockWindows::make_default() {
create_func=create_func_windows;
}
RWLockWindows::RWLockWindows() {
InitializeSRWLock(&lock);
}
RWLockWindows::~RWLockWindows() {
}
#endif
|