summaryrefslogtreecommitdiff
path: root/drivers/windows
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-01-08 11:13:12 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-01-08 11:13:12 -0300
commit263d5fcff86ff4b34b2a19bfe66b79e93f6bb976 (patch)
tree8cca09ddc9692d64e0c2b3098faf97cc1541fb1a /drivers/windows
parentaa60e02cf602c9c54b54eee257b3bfa675724788 (diff)
Added missing readers writers lock to windows, should compile and run again..
Diffstat (limited to 'drivers/windows')
-rw-r--r--drivers/windows/rw_lock_windows.cpp72
-rw-r--r--drivers/windows/rw_lock_windows.h37
2 files changed, 109 insertions, 0 deletions
diff --git a/drivers/windows/rw_lock_windows.cpp b/drivers/windows/rw_lock_windows.cpp
new file mode 100644
index 0000000000..0da7bf4bd5
--- /dev/null
+++ b/drivers/windows/rw_lock_windows.cpp
@@ -0,0 +1,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
diff --git a/drivers/windows/rw_lock_windows.h b/drivers/windows/rw_lock_windows.h
new file mode 100644
index 0000000000..c089c31c33
--- /dev/null
+++ b/drivers/windows/rw_lock_windows.h
@@ -0,0 +1,37 @@
+#ifndef RWLOCKWINDOWS_H
+#define RWLOCKWINDOWS_H
+
+#if defined(WINDOWS_ENABLED)
+
+#include <windows.h>
+#include "os/rw_lock.h"
+
+class RWLockWindows : public RWLock {
+
+
+ SRWLOCK lock;
+
+ static RWLock *create_func_windows();
+
+public:
+
+ virtual void read_lock();
+ virtual void read_unlock();
+ virtual Error read_try_lock();
+
+ virtual void write_lock();
+ virtual void write_unlock();
+ virtual Error write_try_lock();
+
+ static void make_default();
+
+ RWLockWindows();
+
+ ~RWLockWindows();
+
+};
+
+#endif
+
+
+#endif // RWLOCKWINDOWS_H