Added missing readers writers lock to windows, should compile and run again..
This commit is contained in:
parent
aa60e02cf6
commit
263d5fcff8
3 changed files with 111 additions and 0 deletions
72
drivers/windows/rw_lock_windows.cpp
Normal file
72
drivers/windows/rw_lock_windows.cpp
Normal file
|
@ -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
|
37
drivers/windows/rw_lock_windows.h
Normal file
37
drivers/windows/rw_lock_windows.h
Normal file
|
@ -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
|
|
@ -34,6 +34,7 @@
|
|||
#include "drivers/windows/thread_windows.h"
|
||||
#include "drivers/windows/semaphore_windows.h"
|
||||
#include "drivers/windows/mutex_windows.h"
|
||||
#include "drivers/windows/rw_lock_windows.h"
|
||||
#include "main/main.h"
|
||||
#include "drivers/windows/file_access_windows.h"
|
||||
#include "drivers/windows/dir_access_windows.h"
|
||||
|
@ -180,6 +181,7 @@ void OS_Windows::initialize_core() {
|
|||
ThreadWindows::make_default();
|
||||
SemaphoreWindows::make_default();
|
||||
MutexWindows::make_default();
|
||||
RWLockWindows::make_default();
|
||||
|
||||
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES);
|
||||
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA);
|
||||
|
|
Loading…
Reference in a new issue