From 8883732648239223736a11f94022689ae6441f43 Mon Sep 17 00:00:00 2001 From: fchn289 Date: Wed, 31 Jan 2024 13:35:08 +0800 Subject: [PATCH] ThreadBack: fix race found by tsan --- src/log/UniCoutLog.hpp | 2 ++ src/log/UniSmartLog.hpp | 2 ++ ut/thread/ThreadBackTest.cpp | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/log/UniCoutLog.hpp b/src/log/UniCoutLog.hpp index e6f20bb..6f62090 100644 --- a/src/log/UniCoutLog.hpp +++ b/src/log/UniCoutLog.hpp @@ -13,6 +13,8 @@ // // - CORE: // . cout +// +// - NOT MT safe: since (static) member; so shall ONLY use in main thread // *********************************************************************************************** #ifndef UNI_COUT_LOG_HPP_ #define UNI_COUT_LOG_HPP_ diff --git a/src/log/UniSmartLog.hpp b/src/log/UniSmartLog.hpp index ca521de..490f4e4 100644 --- a/src/log/UniSmartLog.hpp +++ b/src/log/UniSmartLog.hpp @@ -10,6 +10,8 @@ // // - CORE: // . smartLog_ +// +// - NOT MT safe: since (static) member; so shall ONLY use in main thread // *********************************************************************************************** #ifndef UNI_SMART_LOG_HPP_ #define UNI_SMART_LOG_HPP_ diff --git a/ut/thread/ThreadBackTest.cpp b/ut/thread/ThreadBackTest.cpp index 495f693..082687f 100644 --- a/ut/thread/ThreadBackTest.cpp +++ b/ut/thread/ThreadBackTest.cpp @@ -60,7 +60,7 @@ TEST_F(ThreadBackTest, GOLD_entryFn_inNewThread_thenBackFn_inMainThread_withSema { EXPECT_NE(this_thread::get_id(), mt_threadID) << "REQ: in new thread"; mt_threadID = this_thread::get_id(); - DBG("MT_ThreadEntryFN(): thread id=" << mt_threadID); + HID("MT_ThreadEntryFN(): thread id=" << mt_threadID); // not MT safe but debug only return true; }, // ThreadBackFN