OpenBarnyard
 
Loading...
Searching...
No Matches
T2Mutex_Win.cpp
Go to the documentation of this file.
1#include "ToshiPCH.h"
2#include "T2Mutex_Win.h"
3
4#include <Windows.h>
5
6//-----------------------------------------------------------------------------
7// Enables memory debugging.
8// Note: Should be the last include!
9//-----------------------------------------------------------------------------
10#include "Core/TMemoryDebugOn.h"
11
13
15{
16 Destroy();
17 m_Mutex = CreateMutexA( NULL, FALSE, NULL );
18 TASSERT( m_Mutex != NULL, "Failed to create mutex" );
19 return TTRUE;
20}
21
23{
24 TASSERT( m_Mutex != NULL, "Mutex is NULL" );
25
26 DWORD waitForMs = ( flags & Flags_DoNotWait ) ? 0 : INFINITE;
27 DWORD result = WaitForSingleObject( m_Mutex, waitForMs );
28
29 return result == WAIT_OBJECT_0;
30}
31
33{
34 TASSERT( m_Mutex != NULL, "Mutex is NULL" );
35 return ReleaseMutex( m_Mutex );
36}
37
39{
40 CloseHandle( m_Mutex );
41 m_Mutex = NULL;
42}
43
#define TASSERT(X,...)
Definition Defines.h:138
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
TBOOL Lock(Flags flags=Flags_Standard)
TBOOL Create()
@ Flags_DoNotWait
Definition T2Mutex_Win.h:12
void Destroy()
TBOOL Unlock()
TUINT32 Flags
Definition T2Mutex_Win.h:8