ReactOS 0.4.15-dev-8058-ga7cbb60
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
13{
16
17public:
19 {
20 }
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 {
36 m_hMutex = NULL;
37 }
38 m_bInit = FALSE;
39 }
40
42 {
43 DWORD dwWait = ::WaitForSingleObject(m_hMutex, 5000);
44 return (dwWait == WAIT_OBJECT_0) || (dwWait == WAIT_ABANDONED);
45 }
46 void Leave()
47 {
49 }
50};
void Uninit()
Definition: cicmutex.h:31
~CicMutex()
Definition: cicmutex.h:21
void Init(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszMutexName)
Definition: cicmutex.h:26
BOOL m_bInit
Definition: cicmutex.h:15
void Leave()
Definition: cicmutex.h:46
HANDLE m_hMutex
Definition: cicmutex.h:14
CicMutex()
Definition: cicmutex.h:18
BOOL Enter()
Definition: cicmutex.h:41
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
#define WAIT_ABANDONED
Definition: winbase.h:412
#define CreateMutex
Definition: winbase.h:3756
#define WAIT_OBJECT_0
Definition: winbase.h:406
const CHAR * LPCTSTR
Definition: xmlstorage.h:193