https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eaa975c54e6bbc467e70f…
commit eaa975c54e6bbc467e70fc5b1de3bef4fafd93d0
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Dec 22 12:13:27 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Fri Dec 22 12:13:27 2023 +0900
[SDK] Add <cicero/cicmutex.h>
CORE-19361
---
sdk/include/reactos/cicero/cicmutex.h | 50 +++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/sdk/include/reactos/cicero/cicmutex.h
b/sdk/include/reactos/cicero/cicmutex.h
new file mode 100644
index 00000000000..9c98146e8c0
--- /dev/null
+++ b/sdk/include/reactos/cicero/cicmutex.h
@@ -0,0 +1,50 @@
+/*
+ * PROJECT: ReactOS Cicero
+ * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE: Cicero mutex handling
+ * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
+ */
+
+#pragma once
+
+#include "cicbase.h"
+
+class CicMutex
+{
+ HANDLE m_hMutex;
+ BOOL m_bInit;
+
+public:
+ CicMutex() : m_hMutex(NULL), m_bInit(FALSE)
+ {
+ }
+ ~CicMutex()
+ {
+ Uninit();
+ }
+
+ void Init(LPSECURITY_ATTRIBUTES lpSA, LPCWSTR pszMutexName)
+ {
+ m_hMutex = ::CreateMutexW(lpSA, FALSE, pszMutexName);
+ m_bInit = TRUE;
+ }
+ void Uninit()
+ {
+ if (m_hMutex)
+ {
+ ::CloseHandle(m_hMutex);
+ m_hMutex = NULL;
+ }
+ m_bInit = FALSE;
+ }
+
+ BOOL Enter()
+ {
+ DWORD dwWait = ::WaitForSingleObject(m_hMutex, 5000);
+ return (dwWait == WAIT_OBJECT_0) || (dwWait == WAIT_ABANDONED);
+ }
+ void Leave()
+ {
+ ::ReleaseMutex(m_hMutex);
+ }
+};