From 9a973be7baadfcdd793656dfb23fdc10aa3a8ee1 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 27 Jul 2024 14:15:51 +0200 Subject: [PATCH] fix: Background service thread names --- lib/libimhex/include/hex/api/content_registry.hpp | 2 +- lib/libimhex/source/api/content_registry.cpp | 8 ++++---- plugins/builtin/source/content/background_services.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/libimhex/include/hex/api/content_registry.hpp b/lib/libimhex/include/hex/api/content_registry.hpp index 29a1fb24b..c6424336d 100644 --- a/lib/libimhex/include/hex/api/content_registry.hpp +++ b/lib/libimhex/include/hex/api/content_registry.hpp @@ -1273,7 +1273,7 @@ namespace hex { void stopServices(); } - void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback); + void registerService(Lang name, const impl::Callback &callback); } /* Network Communication Interface Registry. Allows adding new communication interface endpoints */ diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 0de867236..8b053e475 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -1235,13 +1235,13 @@ namespace hex { } - void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback) { - log::debug("Registered new background service: {}", unlocalizedName.get()); + void registerService(Lang name, const impl::Callback &callback) { + log::debug("Registered new background service: {}", name.get()); impl::s_services->emplace_back( - unlocalizedName, + name, std::jthread([=](const std::stop_token &stopToken){ - TaskManager::setCurrentThreadName(Lang(unlocalizedName)); + TaskManager::setCurrentThreadName(name); while (!stopToken.stop_requested()) { callback(); std::this_thread::sleep_for(std::chrono::milliseconds(50)); diff --git a/plugins/builtin/source/content/background_services.cpp b/plugins/builtin/source/content/background_services.cpp index 3501c726a..cb43cc49a 100644 --- a/plugins/builtin/source/content/background_services.cpp +++ b/plugins/builtin/source/content/background_services.cpp @@ -111,8 +111,8 @@ namespace hex::plugin::builtin { s_autoBackupTime = value.get(0) * 30; }); - ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface", handleNetworkInterfaceService); - ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup", handleAutoBackup); + ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.network_interface"_lang, handleNetworkInterfaceService); + ContentRegistry::BackgroundServices::registerService("hex.builtin.background_service.auto_backup"_lang, handleAutoBackup); EventProviderDirtied::subscribe([](prv::Provider *) { s_dataDirty = true;