From 0402646f7ca11849d5135ef38926e9f59312fd27 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 5 Feb 2022 01:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=91=BD=E5=90=8D=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E6=AD=A7=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- src/Common/config.h | 64 ++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index b4967605..40c09a48 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit b49676057e05bed1b43070c99bc4e541f2302526 +Subproject commit 40c09a4865026de94cdc1ad874aeba580bf15fdf diff --git a/src/Common/config.h b/src/Common/config.h index 8793e921..5540d213 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -103,45 +103,45 @@ extern const std::string kBroadcastReloadConfig; #define BroadcastReloadConfigArgs void #define ReloadConfigTag ((void *)(0xFF)) -#define RELOAD_KEY(arg,key) \ - do { \ - decltype(arg) arg##_tmp = toolkit::mINI::Instance()[key]; \ - if (arg == arg##_tmp) { \ - return; \ - } \ - arg = arg##_tmp; \ - InfoL << "reload config:" << key << "=" << arg; \ +#define RELOAD_KEY(arg,key) \ + do { \ + decltype(arg) arg##_tmp = ::toolkit::mINI::Instance()[key]; \ + if (arg == arg##_tmp) { \ + return; \ + } \ + arg = arg##_tmp; \ + InfoL << "reload config:" << key << "=" << arg; \ } while(0) //监听某个配置发送变更 -#define LISTEN_RELOAD_KEY(arg, key, ...) \ - do { \ - static toolkit::onceToken s_token_listen([](){ \ - toolkit::NoticeCenter::Instance().addListener(ReloadConfigTag, \ - Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs) { \ - __VA_ARGS__; \ - }); \ - }); \ +#define LISTEN_RELOAD_KEY(arg, key, ...) \ + do { \ + static ::toolkit::onceToken s_token_listen([](){ \ + ::toolkit::NoticeCenter::Instance().addListener(ReloadConfigTag, \ + Broadcast::kBroadcastReloadConfig,[](BroadcastReloadConfigArgs) { \ + __VA_ARGS__; \ + }); \ + }); \ } while(0) -#define GET_CONFIG(type, arg, key) \ - static type arg = toolkit::mINI::Instance()[key]; \ - LISTEN_RELOAD_KEY(arg, key, { \ - RELOAD_KEY(arg, key); \ +#define GET_CONFIG(type, arg, key) \ + static type arg = ::toolkit::mINI::Instance()[key]; \ + LISTEN_RELOAD_KEY(arg, key, { \ + RELOAD_KEY(arg, key); \ }); -#define GET_CONFIG_FUNC(type, arg, key, ...) \ - static type arg; \ - do { \ - static toolkit::onceToken s_token_set([](){ \ - static auto lam = __VA_ARGS__ ; \ - static auto arg##_str = toolkit::mINI::Instance()[key]; \ - arg = lam(arg##_str); \ - LISTEN_RELOAD_KEY(arg, key, { \ - RELOAD_KEY(arg##_str, key); \ - arg = lam(arg##_str); \ - }); \ - }); \ +#define GET_CONFIG_FUNC(type, arg, key, ...) \ + static type arg; \ + do { \ + static ::toolkit::onceToken s_token_set([](){ \ + static auto lam = __VA_ARGS__ ; \ + static auto arg##_str = ::toolkit::mINI::Instance()[key]; \ + arg = lam(arg##_str); \ + LISTEN_RELOAD_KEY(arg, key, { \ + RELOAD_KEY(arg##_str, key); \ + arg = lam(arg##_str); \ + }); \ + }); \ } while(0) } //namespace Broadcast