wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
shared_mutex.cpp
Go to the documentation of this file.
1
#include <
wowlib/core/shared_mutex.hpp
>
2
3
#if defined(_WIN32) && defined(__GNUC__) && !defined(__clang__)
4
5
// ifndef-guarded: MSYS2's g++ already predefines NOMINMAX.
6
#ifndef WIN32_LEAN_AND_MEAN
7
#define WIN32_LEAN_AND_MEAN
8
#endif
9
#ifndef NOMINMAX
10
#define NOMINMAX
11
#endif
12
#include <windows.h>
13
14
static_assert
(
sizeof
(
void
*) ==
sizeof
(SRWLOCK),
"SRWLOCK must stay pointer-sized for the header's inline storage"
);
15
namespace
wowlib
{
16
void
SharedMutex::lock() noexcept {
17
AcquireSRWLockExclusive(
reinterpret_cast<
PSRWLOCK
>
(&_lock));
18
}
19
20
bool
SharedMutex::try_lock() noexcept {
21
return
TryAcquireSRWLockExclusive(
reinterpret_cast<
PSRWLOCK
>
(&_lock)) != 0;
22
}
23
24
void
SharedMutex::unlock() noexcept {
25
ReleaseSRWLockExclusive(
reinterpret_cast<
PSRWLOCK
>
(&_lock));
26
}
27
28
void
SharedMutex::lock_shared() noexcept {
29
AcquireSRWLockShared(
reinterpret_cast<
PSRWLOCK
>
(&_lock));
30
}
31
32
bool
SharedMutex::try_lock_shared() noexcept {
33
return
TryAcquireSRWLockShared(
reinterpret_cast<
PSRWLOCK
>
(&_lock)) != 0;
34
}
35
36
void
SharedMutex::unlock_shared() noexcept {
37
ReleaseSRWLockShared(
reinterpret_cast<
PSRWLOCK
>
(&_lock));
38
}
39
}
40
41
#endif
wowlib
Definition
detail.hpp:29
shared_mutex.hpp
Reader/writer mutex used across the library.
src
wowlib
core
shared_mutex.cpp
Generated by
1.17.0