From ff1e79f7413d042d1e9fcad2a3dc1329aca23cdd Mon Sep 17 00:00:00 2001 From: brinkqiang Date: Wed, 25 Dec 2024 11:24:15 +0800 Subject: [PATCH] add --- include/dmtimermodule.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/dmtimermodule.h b/include/dmtimermodule.h index 0b95784..29fdba5 100644 --- a/include/dmtimermodule.h +++ b/include/dmtimermodule.h @@ -84,7 +84,13 @@ static inline uint32_t GetTickCount32() { #ifdef _WIN32 static std::once_flag initializedFlag; - std::call_once(initializedFlag, []() { timeBeginPeriod(1); }); + std::call_once(initializedFlag, []() { + static auto t = timeBeginPeriod(1); + std::atexit([](){ + timeEndPeriod(t); + }); + }); + #endif auto now = std::chrono::high_resolution_clock::now();