From b794e46e15683edeff41d982e3dd7adfdf055a67 Mon Sep 17 00:00:00 2001 From: lorry li Date: Wed, 27 Sep 2023 16:53:24 -0400 Subject: [PATCH] Write the boot hotfix file in background. [REVIEW] [at]michael.atchison [at]michael.kirzinger [at]joe.barnes #jira UE-196689 #rb [at]michael.atchison [at]michael.kirzinger [CL 28292288 by lorry li in ue5-main branch] --- .../Core/Private/Misc/ConfigUtilities.cpp | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Engine/Source/Runtime/Core/Private/Misc/ConfigUtilities.cpp b/Engine/Source/Runtime/Core/Private/Misc/ConfigUtilities.cpp index 517172a5bccd..bae79845e3c6 100644 --- a/Engine/Source/Runtime/Core/Private/Misc/ConfigUtilities.cpp +++ b/Engine/Source/Runtime/Core/Private/Misc/ConfigUtilities.cpp @@ -6,12 +6,15 @@ #include "HAL/IConsoleManager.h" #include "Misc/CoreDelegates.h" #include "Misc/FileHelper.h" +#include "Tasks/Pipe.h" #define UE_HOTFIX_FOR_NEXT_BOOT_FILENAME TEXT("HotfixForNextBoot.txt") namespace UE::ConfigUtilities { +UE::Tasks::FPipe AsyncTaskPipe( TEXT("SaveHotfixForNextBootPipe") ); + const TCHAR* ConvertValueFromHumanFriendlyValue( const TCHAR* Value ) { static const TCHAR* OnValue = TEXT("1"); @@ -94,23 +97,28 @@ void SaveCVarForNextBoot(const TCHAR* Key, const TCHAR* Value) return; } - TMap CVarsToSave; + FString StrKey(Key); + FString StrValue(Value); - // Read from file, in case there are more than one cvar hotfix event in same run - LoadCVarsFromFileForNextBoot(CVarsToSave); + AsyncTaskPipe.Launch(UE_SOURCE_LOCATION, [StrKey, StrValue] { + TMap CVarsToSave; - CVarsToSave.FindOrAdd(Key) = Value; + // Read from file, in case there are more than one cvar hotfix event in same run + LoadCVarsFromFileForNextBoot(CVarsToSave); - FString ContentToSave; - for (const TPair& CVarPair : CVarsToSave) - { - ContentToSave.Append(FString::Format(TEXT("{0}={1}\r\n"), { CVarPair.Key, CVarPair.Value })); - } + CVarsToSave.FindOrAdd(StrKey) = StrValue; - const FString FullPath = FPaths::ProjectPersistentDownloadDir() / UE_HOTFIX_FOR_NEXT_BOOT_FILENAME; - FFileHelper::SaveStringToFile(ContentToSave, *FullPath); + FString ContentToSave; + for (const TPair& CVarPair : CVarsToSave) + { + ContentToSave.Append(FString::Format(TEXT("{0}={1}\r\n"), { CVarPair.Key, CVarPair.Value })); + } - UE_LOG(LogConfig, Log, TEXT("Local boot hotfix file [%s] saved with hotfixed CVar: %s=%s"), *FullPath, Key, Value); + const FString FullPath = FPaths::ProjectPersistentDownloadDir() / UE_HOTFIX_FOR_NEXT_BOOT_FILENAME; + FFileHelper::SaveStringToFile(ContentToSave, *FullPath); + + UE_LOG(LogConfig, Log, TEXT("Local boot hotfix file [%s] saved with hotfixed CVar: %s=%s"), *FullPath, *StrKey, *StrValue); + }, LowLevelTasks::ETaskPriority::BackgroundLow); #endif // !UE_SERVER }