diff options
Diffstat (limited to 'drivers/windows/mutex_windows.cpp')
-rw-r--r-- | drivers/windows/mutex_windows.cpp | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/drivers/windows/mutex_windows.cpp b/drivers/windows/mutex_windows.cpp index 6ae7e52124..bacf89efbb 100644 --- a/drivers/windows/mutex_windows.cpp +++ b/drivers/windows/mutex_windows.cpp @@ -31,76 +31,68 @@ #ifdef WINDOWS_ENABLED - - void MutexWindows::lock() { #ifdef WINDOWS_USE_MUTEX - WaitForSingleObject(mutex,INFINITE); + WaitForSingleObject(mutex, INFINITE); #else - EnterCriticalSection( &mutex ); + EnterCriticalSection(&mutex); #endif } - void MutexWindows::unlock() { #ifdef WINDOWS_USE_MUTEX ReleaseMutex(mutex); #else - LeaveCriticalSection( &mutex ); + LeaveCriticalSection(&mutex); #endif } Error MutexWindows::try_lock() { #ifdef WINDOWS_USE_MUTEX - return (WaitForSingleObject(mutex,0)==WAIT_TIMEOUT)?ERR_BUSY:OK; + return (WaitForSingleObject(mutex, 0) == WAIT_TIMEOUT) ? ERR_BUSY : OK; #else - if (TryEnterCriticalSection( &mutex )) - return OK; - else - return ERR_BUSY; + if (TryEnterCriticalSection(&mutex)) + return OK; + else + return ERR_BUSY; #endif - } Mutex *MutexWindows::create_func_windows(bool p_recursive) { - return memnew( MutexWindows ); + return memnew(MutexWindows); } void MutexWindows::make_default() { - create_func=create_func_windows; + create_func = create_func_windows; } MutexWindows::MutexWindows() { - + #ifdef WINDOWS_USE_MUTEX - mutex = CreateMutex( NULL, FALSE, NULL ); + mutex = CreateMutex(NULL, FALSE, NULL); +#else +#ifdef UWP_ENABLED + InitializeCriticalSectionEx(&mutex, 0, 0); #else - #ifdef UWP_ENABLED - InitializeCriticalSectionEx( &mutex, 0, 0 ); - #else - InitializeCriticalSection( &mutex ); - #endif + InitializeCriticalSection(&mutex); +#endif #endif - } - MutexWindows::~MutexWindows() { #ifdef WINDOWS_USE_MUTEX - CloseHandle(mutex); + CloseHandle(mutex); #else - DeleteCriticalSection(&mutex); + DeleteCriticalSection(&mutex); #endif - } - #endif |