mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(thread): implement CSRWLock::Enter and CSRWLock::Leave for windows (#1)
This commit is contained in:
parent
8210d368f6
commit
2fb9fd284c
5 changed files with 61 additions and 6 deletions
|
|
@ -5,6 +5,14 @@ file(GLOB STORM_SOURCES
|
|||
"thread/*.cpp"
|
||||
)
|
||||
|
||||
if(WHOA_PLATFORM_WIN)
|
||||
file(GLOB STORM_WIN_SOURCES
|
||||
"win/*.cpp"
|
||||
"thread/win/*.cpp"
|
||||
)
|
||||
list(APPEND STORM_SOURCES ${STORM_WIN_SOURCES})
|
||||
endif()
|
||||
|
||||
if(WHOA_PLATFORM_MAC)
|
||||
file(GLOB STORM_MAC_SOURCES
|
||||
"mac/*.cpp"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include "storm/thread/CSRWLock.hpp"
|
||||
|
||||
void CSRWLock::Enter(int32_t forwriting) {
|
||||
#ifdef WHOA_PLATFORM_WIN
|
||||
// TODO
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
SRWLock::SURWLockEnter(&this->m_opaqueData, forwriting);
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
|
|
@ -15,8 +15,8 @@ void CSRWLock::Enter(int32_t forwriting) {
|
|||
}
|
||||
|
||||
void CSRWLock::Leave(int32_t fromwriting) {
|
||||
#ifdef WHOA_PLATFORM_WIN
|
||||
// TODO
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
SRWLock::SURWLockLeave(&this->m_opaqueData, fromwriting);
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
#include "storm/thread/win/SRWLock.hpp"
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
|
@ -10,8 +14,8 @@
|
|||
class CSRWLock {
|
||||
public:
|
||||
// Member variables
|
||||
#ifdef WHOA_PLATFORM_WIN
|
||||
char m_opaqueData[12];
|
||||
#if defined(WHOA_PLATFORM_WIN)
|
||||
SRWLock::SURWLOCK m_opaqueData;
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_PLATFORM_MAC) || defined(WHOA_PLATFORM_LINUX)
|
||||
|
|
|
|||
17
storm/thread/win/SRWLock.cpp
Normal file
17
storm/thread/win/SRWLock.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include "storm/thread/win/SRWLock.hpp"
|
||||
|
||||
void SRWLock::SUNNLockEnter(volatile SUNNLOCK* sunnlock) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void SRWLock::SUNNLockLeave(volatile SUNNLOCK* sunnlock) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void SRWLock::SURWLockEnter(volatile SURWLOCK* surwlock, int32_t forwriting) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void SRWLock::SURWLockLeave(volatile SURWLOCK* surwlock, int32_t fromwriting) {
|
||||
// TODO
|
||||
}
|
||||
26
storm/thread/win/SRWLock.hpp
Normal file
26
storm/thread/win/SRWLock.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef STORM_THREAD_WIN_S_RW_LOCK_HPP
|
||||
#define STORM_THREAD_WIN_S_RW_LOCK_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class SRWLock {
|
||||
public:
|
||||
// Types
|
||||
struct SUNNLOCK {
|
||||
int32_t m_state;
|
||||
int32_t m_event;
|
||||
};
|
||||
|
||||
struct SURWLOCK {
|
||||
SRWLock::SUNNLOCK m_mutex;
|
||||
int32_t m_readerEvent;
|
||||
};
|
||||
|
||||
// Static functions
|
||||
static void SUNNLockEnter(volatile SUNNLOCK* sunnlock);
|
||||
static void SUNNLockLeave(volatile SUNNLOCK* sunnlock);
|
||||
static void SURWLockEnter(volatile SURWLOCK* surwlock, int32_t forwriting);
|
||||
static void SURWLockLeave(volatile SURWLOCK* surwlock, int32_t fromwriting);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue