ReactOS
0.4.16-dev-136-g52192f1
cicmutex.h
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS Cicero
3
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4
* PURPOSE: Cicero mutex handling
5
* COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6
*/
7
8
#pragma once
9
10
#include "
cicbase.h
"
11
12
class
CicMutex
13
{
14
HANDLE
m_hMutex
;
15
BOOL
m_bInit
;
16
17
public
:
18
CicMutex
() :
m_hMutex
(
NULL
),
m_bInit
(
FALSE
)
19
{
20
}
21
~CicMutex
()
22
{
23
Uninit
();
24
}
25
26
void
Init
(
LPSECURITY_ATTRIBUTES
lpSA,
LPCTSTR
pszMutexName)
27
{
28
m_hMutex
=
::CreateMutex
(lpSA,
FALSE
, pszMutexName);
29
m_bInit
=
TRUE
;
30
}
31
void
Uninit
()
32
{
33
if
(
m_hMutex
)
34
{
35
::CloseHandle
(
m_hMutex
);
36
m_hMutex
=
NULL
;
37
}
38
m_bInit
=
FALSE
;
39
}
40
41
BOOL
Enter
()
42
{
43
DWORD
dwWait =
::WaitForSingleObject
(
m_hMutex
, 5000);
44
return
(dwWait ==
WAIT_OBJECT_0
) || (dwWait ==
WAIT_ABANDONED
);
45
}
46
void
Leave
()
47
{
48
::ReleaseMutex
(
m_hMutex
);
49
}
50
};
cicbase.h
CicMutex
Definition:
cicmutex.h:13
CicMutex::Uninit
void Uninit()
Definition:
cicmutex.h:31
CicMutex::~CicMutex
~CicMutex()
Definition:
cicmutex.h:21
CicMutex::Init
void Init(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszMutexName)
Definition:
cicmutex.h:26
CicMutex::m_bInit
BOOL m_bInit
Definition:
cicmutex.h:15
CicMutex::Leave
void Leave()
Definition:
cicmutex.h:46
CicMutex::m_hMutex
HANDLE m_hMutex
Definition:
cicmutex.h:14
CicMutex::CicMutex
CicMutex()
Definition:
cicmutex.h:18
CicMutex::Enter
BOOL Enter()
Definition:
cicmutex.h:41
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
CloseHandle
#define CloseHandle
Definition:
compat.h:739
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
void
Definition:
nsiface.idl:2307
_SECURITY_ATTRIBUTES
Definition:
compat.h:191
WaitForSingleObject
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition:
synch.c:82
ReleaseMutex
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition:
synch.c:618
WAIT_ABANDONED
#define WAIT_ABANDONED
Definition:
winbase.h:412
CreateMutex
#define CreateMutex
Definition:
winbase.h:3756
WAIT_OBJECT_0
#define WAIT_OBJECT_0
Definition:
winbase.h:406
LPCTSTR
const CHAR * LPCTSTR
Definition:
xmlstorage.h:193
sdk
lib
cicero
cicmutex.h
Generated on Tue Oct 15 2024 06:13:03 for ReactOS by
1.9.6