1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Give all threads created by client human-readable name for debug

This commit is contained in:
Ivan Savenko 2023-08-20 23:09:17 +03:00
parent 1bad0e96ef
commit 142889e3a5
6 changed files with 19 additions and 6 deletions

View File

@ -27,11 +27,12 @@
#include "render/IScreenHandler.h"
#include "render/Graphics.h"
#include "../lib/filesystem/Filesystem.h"
#include "../lib/CConfigHandler.h"
#include "../lib/CGeneralTextHandler.h"
#include "../lib/CThreadHelper.h"
#include "../lib/VCMIDirs.h"
#include "../lib/VCMI_Lib.h"
#include "../lib/CConfigHandler.h"
#include "../lib/filesystem/Filesystem.h"
#include "../lib/logging/CBasicLogConfigurator.h"
@ -297,7 +298,11 @@ int main(int argc, char * argv[])
#ifndef VCMI_NO_THREADED_LOAD
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
boost::thread loading(init);
boost::thread loading([]()
{
setThreadName("initialize");
init();
});
#else
init();
#endif
@ -429,6 +434,7 @@ void playIntro()
static void mainLoop()
{
setThreadName("MainGUI");
inGuiThread.reset(new bool(true));
while(1) //main SDL events loop

View File

@ -76,6 +76,7 @@
#include "../lib/UnlockGuard.h"
#include "../lib/RoadHandler.h"
#include "../lib/TerrainHandler.h"
#include "../lib/CThreadHelper.h"
#include "CServerHandler.h"
// FIXME: only needed for CGameState::mutex
#include "../lib/gameState/CGameState.h"
@ -1933,6 +1934,8 @@ void CPlayerInterface::setMovementStatus(bool value)
void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
{
setThreadName("doMoveHero");
int i = 1;
auto getObj = [&](int3 coord, bool ignoreHero)
{

View File

@ -817,7 +817,7 @@ public:
void CServerHandler::threadHandleConnection()
{
setThreadName("CServerHandler::threadHandleConnection");
setThreadName("threadHandleConnection");
c->enterLobbyConnectionMode();
try
@ -898,7 +898,7 @@ void CServerHandler::visitForClient(CPackForClient & clientPack)
void CServerHandler::threadRunServer()
{
#if !defined(VCMI_MOBILE)
setThreadName("CServerHandler::threadRunServer");
setThreadName("threadRunServer");
const std::string logName = (VCMIDirs::get().userLogsPath() / "server_log.txt").string();
std::string comm = VCMIDirs::get().serverPath().string()
+ " --port=" + std::to_string(getHostPort())

View File

@ -27,6 +27,7 @@
#include "../../CCallback.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CThreadHelper.h"
#include "../../lib/TextOperations.h"
#include "../../lib/mapObjects/CArmedInstance.h"
@ -255,6 +256,7 @@ void CInGameConsole::endEnteringText(bool processEnteredText)
//some commands like gosolo don't work when executed from GUI thread
auto threadFunction = [=]()
{
setThreadName("processCommand");
ClientCommandManager commandController;
commandController.processCommand(txt.substr(1), true);
};

View File

@ -43,6 +43,7 @@
#include "../../lib/NetPacks.h"
#include "../../lib/UnlockGuard.h"
#include "../../lib/TerrainHandler.h"
#include "../../lib/CThreadHelper.h"
BattleInterface::BattleInterface(const CCreatureSet *army1, const CCreatureSet *army2,
const CGHeroInstance *hero1, const CGHeroInstance *hero2,
@ -731,6 +732,7 @@ void BattleInterface::requestAutofightingAIToTakeAction()
// HOWEVER this thread won't atttempt to lock game state, potentially leading to races
boost::thread aiThread([this, activeStack]()
{
setThreadName("autofightingAI");
curInt->autofightingAI->activeStack(activeStack);
});
aiThread.detach();

View File

@ -567,7 +567,7 @@ void CSimpleJoinScreen::startConnectThread(const std::string & addr, ui16 port)
void CSimpleJoinScreen::connectThread(const std::string & addr, ui16 port)
{
setThreadName("CSimpleJoinScreen::connectThread");
setThreadName("connectThread");
if(!addr.length())
CSH->startLocalServerAndConnect();
else