From 5dc08ee6803abeadd0897a1536b5437715e2f0d3 Mon Sep 17 00:00:00 2001 From: Awin Huang Date: Tue, 18 Mar 2025 08:43:56 +0800 Subject: [PATCH] vault backup: 2025-03-18 08:43:56 Affected files: 20.01. Programming/Prompting.md --- 20.01. Programming/Prompting.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/20.01. Programming/Prompting.md b/20.01. Programming/Prompting.md index 9acdc69..2e82c57 100644 --- a/20.01. Programming/Prompting.md +++ b/20.01. Programming/Prompting.md @@ -18,5 +18,13 @@ Add docstring in English to each classes and functions. 編譯環境: Visual Studio 2022 Python 版本: 3.12 +# Create global mutex +Use `ctypes` and Win32Api `CreateMutex` to create a global mutex here. Use class to wrap it. +This mutex shoid has these features: +1. When user instantiate this class, use Win32api `OpenMutex` to try to open this global mutex, because this mutex mybe alreday created in another process. +2. if `OpenMutex` failed, use `CreateMutex` to create the global mutex. +3. this class should provide lock and unlock function, use `WaitForSingleObject` and `ReleaseMutex` to implement it. +4. And, very important, class should has `release` function of mutex. + # 參考來源 \ No newline at end of file