Created
August 16, 2018 11:16
-
-
Save namkazt/9a09b8f51bd5fc95fdf75284690f7795 to your computer and use it in GitHub Desktop.
mutex concept
This file contains hidden or 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
Mutex::Mutex() | |
{ | |
g_isLocked = false; | |
svcCreateMutex(&g_mutexHandle, g_isLocked); | |
} | |
Mutex::~Mutex() | |
{ | |
svcReleaseMutex(g_mutexHandle); | |
} | |
void Mutex::Lock() | |
{ | |
if(g_isLocked) | |
{ | |
svcWaitSynchronization(g_mutexHandle, U64_MAX); | |
}else | |
{ | |
g_isLocked = true; | |
} | |
} | |
void Mutex::Unlock() | |
{ | |
if (g_isLocked) | |
{ | |
svcSignalEvent(g_mutexHandle); | |
g_isLocked = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment