mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(thread): add SCritSect constructor
This commit is contained in:
parent
61d2c8d01e
commit
665f057516
3 changed files with 32 additions and 0 deletions
|
|
@ -1,5 +1,19 @@
|
|||
#include "storm/thread/SCritSect.hpp"
|
||||
|
||||
SCritSect::SCritSect() {
|
||||
#if defined(WHOA_SYSTEM_WIN)
|
||||
InitializeCriticalSection(&this->m_opaqueData);
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
|
||||
pthread_mutex_init(&this->m_mutex, &attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SCritSect::Enter() {
|
||||
#if defined(WHOA_SYSTEM_WIN)
|
||||
EnterCriticalSection(&this->m_opaqueData);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class SCritSect {
|
|||
#endif
|
||||
|
||||
// Member functions
|
||||
SCritSect();
|
||||
void Enter(void);
|
||||
void Leave(void);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue