-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from jac3km4/mutex-spin-lock
Rename SharedMutex and introduce Mutex
- Loading branch information
Showing
20 changed files
with
306 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#ifdef RED4EXT_STATIC_LIB | ||
#include <RED4ext/Mutex.hpp> | ||
#endif | ||
|
||
RED4EXT_INLINE RED4ext::Mutex::Mutex() | ||
{ | ||
InitializeCriticalSection(&m_cs); | ||
} | ||
|
||
RED4EXT_INLINE void RED4ext::Mutex::Lock() | ||
{ | ||
EnterCriticalSection(&m_cs); | ||
} | ||
|
||
RED4EXT_INLINE void RED4ext::Mutex::Unlock() | ||
{ | ||
LeaveCriticalSection(&m_cs); | ||
} | ||
|
||
RED4EXT_INLINE void RED4ext::Mutex::lock() | ||
{ | ||
Lock(); | ||
} | ||
|
||
RED4EXT_INLINE void RED4ext::Mutex::unlock() | ||
{ | ||
Unlock(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include <RED4ext/Common.hpp> | ||
#include <windows.h> | ||
|
||
namespace RED4ext | ||
{ | ||
struct Mutex | ||
{ | ||
Mutex(); | ||
Mutex(const Mutex&) = delete; | ||
Mutex(Mutex&&) = delete; | ||
Mutex& operator=(const Mutex&) = delete; | ||
Mutex& operator=(Mutex&&) = delete; | ||
|
||
void Lock(); | ||
void Unlock(); | ||
|
||
// -------------------------------------------- | ||
// -- support for lock_guard -- | ||
// -------------------------------------------- | ||
|
||
void lock(); | ||
void unlock(); | ||
|
||
private: | ||
CRITICAL_SECTION m_cs; | ||
}; | ||
RED4EXT_ASSERT_SIZE(Mutex, 40); | ||
} // namespace RED4ext | ||
|
||
#ifdef RED4EXT_HEADER_ONLY | ||
#include <RED4ext/Mutex-inl.hpp> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.