wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
shared_mutex.hpp
Go to the documentation of this file.
1
10#pragma once
11
12#include <shared_mutex>
13
14namespace wowlib {
15#if defined(_WIN32) && defined(__GNUC__) && !defined(__clang__)
19 class SharedMutex {
20 public:
21 SharedMutex() noexcept = default;
22 SharedMutex(const SharedMutex&) = delete;
23 SharedMutex& operator=(const SharedMutex&) = delete;
24
26 void lock() noexcept;
29 bool try_lock() noexcept;
31 void unlock() noexcept;
32
34 void lock_shared() noexcept;
37 bool try_lock_shared() noexcept;
39 void unlock_shared() noexcept;
40
41 private:
42 // SRWLOCK is a single pointer; SRWLOCK_INIT is the null pointer. Kept as
43 // void* so this header never drags in <windows.h>.
44 void* _lock = nullptr;
45 };
46#else
47 using SharedMutex = std::shared_mutex;
48#endif
49}
std::shared_mutex SharedMutex