aboutsummaryrefslogtreecommitdiff
path: root/zencore
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-19 22:35:12 +0200
committerStefan Boberg <[email protected]>2021-09-19 22:35:12 +0200
commitc86315ea955408659eb7ea32798693975e27b9b7 (patch)
tree1ed4be528a0d2f5556cb6137b85bea9238a61dbd /zencore
parentclang-format again (diff)
downloadzen-c86315ea955408659eb7ea32798693975e27b9b7.tar.xz
zen-c86315ea955408659eb7ea32798693975e27b9b7.zip
Changed so Windows also uses the portable std::mutex implementation and reworked some code which would not compile after the change
Diffstat (limited to 'zencore')
-rw-r--r--zencore/include/zencore/thread.h8
-rw-r--r--zencore/thread.cpp16
2 files changed, 1 insertions, 23 deletions
diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h
index e65867ec4..7889682cd 100644
--- a/zencore/include/zencore/thread.h
+++ b/zencore/include/zencore/thread.h
@@ -4,9 +4,7 @@
#include "zencore.h"
-#if !ZEN_PLATFORM_WINDOWS
-# include <shared_mutex>
-#endif
+#include <shared_mutex>
#include <vector>
@@ -66,11 +64,7 @@ public:
};
private:
-#if ZEN_PLATFORM_WINDOWS
- void* m_Srw = nullptr;
-#else
std::shared_mutex m_Mutex;
-#endif
};
/** Basic abstraction of a simple event synchronization mechanism (aka 'binary semaphore')
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index c92cca6de..d4f101454 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -17,41 +17,25 @@ namespace zen {
void
RwLock::AcquireShared()
{
-#if ZEN_PLATFORM_WINDOWS
- AcquireSRWLockShared((PSRWLOCK)&m_Srw);
-#else
m_Mutex.lock_shared();
-#endif
}
void
RwLock::ReleaseShared()
{
-#if ZEN_PLATFORM_WINDOWS
- ReleaseSRWLockShared((PSRWLOCK)&m_Srw);
-#else
m_Mutex.unlock_shared();
-#endif
}
void
RwLock::AcquireExclusive()
{
-#if ZEN_PLATFORM_WINDOWS
- AcquireSRWLockExclusive((PSRWLOCK)&m_Srw);
-#else
m_Mutex.lock();
-#endif
}
void
RwLock::ReleaseExclusive()
{
-#if ZEN_PLATFORM_WINDOWS
- ReleaseSRWLockExclusive((PSRWLOCK)&m_Srw);
-#else
m_Mutex.unlock();
-#endif
}
Event::Event()