implement thread names in debug mode

This commit is contained in:
Lion Kortlepel
2021-03-30 00:30:24 +02:00
parent 940a39ed4e
commit 3094d382ff
9 changed files with 61 additions and 36 deletions

View File

@@ -3,6 +3,8 @@
#include "TConsole.h"
#include <array>
#include <iostream>
#include <map>
#include <thread>
#include <zlib.h>
std::unique_ptr<TConsole> Application::mConsole = std::make_unique<TConsole>();
@@ -65,3 +67,22 @@ std::string DeComp(std::string Compressed) {
std::copy_n(C.begin(), TO, Ret.begin());
return Ret;
}
// thread name stuff
std::map<std::thread::id, std::string> threadNameMap;
std::string ThreadName() {
if (Application::Settings.DebugModeEnabled) {
auto id = std::this_thread::get_id();
if (threadNameMap.find(id) != threadNameMap.end()) {
// found
return threadNameMap.at(id) + " ";
}
}
return "";
}
void RegisterThread(const std::string str) {
threadNameMap[std::this_thread::get_id()] = str;
}