OpenBarnyard
 
Loading...
Searching...
No Matches
T2Mutex Class Reference

#include <T2Mutex_Win.h>

Public Types

enum  Flags_ : Flags { Flags_Standard = 0 , Flags_DoNotWait = 1 }
 
typedef TUINT32 Flags
 

Public Member Functions

constexpr T2Mutex ()
 
 ~T2Mutex ()
 
TBOOL Create ()
 
TBOOL Lock (Flags flags=Flags_Standard)
 
TBOOL Unlock ()
 
void Destroy ()
 
 operator TBOOL () const
 

Detailed Description

Definition at line 5 of file T2Mutex_Win.h.

Member Typedef Documentation

◆ Flags

Definition at line 8 of file T2Mutex_Win.h.

Member Enumeration Documentation

◆ Flags_

Enumerator
Flags_Standard 
Flags_DoNotWait 

Definition at line 9 of file T2Mutex_Win.h.

10 {
13 };
@ Flags_DoNotWait
Definition T2Mutex_Win.h:12
@ Flags_Standard
Definition T2Mutex_Win.h:11

Constructor & Destructor Documentation

◆ T2Mutex()

T2Mutex::T2Mutex ( )
inlineconstexpr

Definition at line 16 of file T2Mutex_Win.h.

17 : m_Mutex( TNULL ) {}
#define TNULL
Definition Typedefs.h:23

◆ ~T2Mutex()

T2Mutex::~T2Mutex ( )
inline

Definition at line 18 of file T2Mutex_Win.h.

18{ Destroy(); }
void Destroy()

Member Function Documentation

◆ Create()

TBOOL T2Mutex::Create ( )

Definition at line 14 of file T2Mutex_Win.cpp.

15{
16 Destroy();
17 m_Mutex = CreateMutexA( NULL, FALSE, NULL );
18 TASSERT( m_Mutex != NULL, "Failed to create mutex" );
19 return TTRUE;
20}
#define TASSERT(X,...)
Definition Defines.h:138
#define TTRUE
Definition Typedefs.h:25

◆ Destroy()

void T2Mutex::Destroy ( )

Definition at line 38 of file T2Mutex_Win.cpp.

39{
40 CloseHandle( m_Mutex );
41 m_Mutex = NULL;
42}

◆ Lock()

TBOOL T2Mutex::Lock ( Flags flags = Flags_Standard)

Definition at line 22 of file T2Mutex_Win.cpp.

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}

◆ operator TBOOL()

T2Mutex::operator TBOOL ( ) const
inline

Definition at line 32 of file T2Mutex_Win.h.

32{ return m_Mutex; }

◆ Unlock()

TBOOL T2Mutex::Unlock ( )

Definition at line 32 of file T2Mutex_Win.cpp.

33{
34 TASSERT( m_Mutex != NULL, "Mutex is NULL" );
35 return ReleaseMutex( m_Mutex );
36}

The documentation for this class was generated from the following files: