From f6427750435cd51961d6ff1c92365fb6598324a2 Mon Sep 17 00:00:00 2001 From: howsohazard <143410553+howsohazard@users.noreply.github.com> Date: Fri, 17 May 2024 13:00:48 -0400 Subject: [PATCH] 20324: Adds get/set_max_num_threads support for trace files, MINOR (#133) --- src/Amalgam/AmalgamTrace.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Amalgam/AmalgamTrace.cpp b/src/Amalgam/AmalgamTrace.cpp index 0a8c1c57..07043e32 100644 --- a/src/Amalgam/AmalgamTrace.cpp +++ b/src/Amalgam/AmalgamTrace.cpp @@ -184,6 +184,34 @@ int32_t RunAmalgamTrace(std::istream *in_stream, std::ostream *out_stream, std:: { response = AMALGAM_VERSION_STRING; } + else if(command == "GET_MAX_NUM_THREADS") + { + #if defined(MULTITHREAD_SUPPORT) + response = std::to_string(Concurrency::GetMaxNumThreads()); + #else + response = FAILURE_RESPONSE; + #endif + } + else if(command == "SET_MAX_NUM_THREADS") + { + #if defined(MULTITHREAD_SUPPORT) + response = SUCCESS_RESPONSE; + try + { + auto num_threads = std::stoll(input); + if(num_threads >= 0) + Concurrency::SetMaxNumThreads(static_cast(num_threads)); + else + response = FAILURE_RESPONSE; + } + catch(...) + { + response = FAILURE_RESPONSE; + } + #else + response = FAILURE_RESPONSE; + #endif + } else if(command == "EXIT") { break;