add thread names
This commit is contained in:
parent
e7b741ebe1
commit
f3f8f2ac5d
62
src/client/component/thread_names.cpp
Normal file
62
src/client/component/thread_names.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "scheduler.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include <utils/thread.hpp>
|
||||
|
||||
namespace thread_names
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void set_thread_names()
|
||||
{
|
||||
static std::unordered_map<int, std::string> thread_names =
|
||||
{
|
||||
{game::THREAD_CONTEXT_MAIN, "Main"},
|
||||
{game::THREAD_CONTEXT_BACKEND, "Backend"}, // Renderer
|
||||
{game::THREAD_CONTEXT_WORKER0, "Worker0"},
|
||||
{game::THREAD_CONTEXT_WORKER1, "Worker1"},
|
||||
{game::THREAD_CONTEXT_WORKER2, "Worker2"},
|
||||
{game::THREAD_CONTEXT_WORKER3, "Worker3"},
|
||||
{game::THREAD_CONTEXT_WORKER4, "Worker4"},
|
||||
{game::THREAD_CONTEXT_WORKER5, "Worker5"},
|
||||
{game::THREAD_CONTEXT_WORKER6, "Worker6"},
|
||||
{game::THREAD_CONTEXT_WORKER7, "Worker7"},
|
||||
{game::THREAD_CONTEXT_SERVER, "Server"},
|
||||
{game::THREAD_CONTEXT_CINEMATIC, "Cinematic"},
|
||||
{game::THREAD_CONTEXT_WINDOW, "Window"},
|
||||
{game::THREAD_CONTEXT_WINDOW, "Input"},
|
||||
{game::THREAD_CONTEXT_DATABASE, "Database"},
|
||||
{game::THREAD_CONTEXT_SOUND_STREAM, "Sound Stream"},
|
||||
{game::THREAD_CONTEXT_SOUND, "Snd stream packet callback"},
|
||||
{game::THREAD_CONTEXT_RECIPE, "Recipe"},
|
||||
};
|
||||
|
||||
for (const auto& thread_name : thread_names)
|
||||
{
|
||||
const auto id = game::threadIds[thread_name.first];
|
||||
if (id)
|
||||
{
|
||||
utils::thread::set_name(id, thread_name.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
set_thread_names();
|
||||
scheduler::once(set_thread_names, scheduler::pipeline::main);
|
||||
scheduler::once(set_thread_names, scheduler::pipeline::renderer);
|
||||
scheduler::once(set_thread_names, scheduler::pipeline::server);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(thread_names::component)
|
@ -412,6 +412,31 @@ namespace game
|
||||
CRITSECT_DEMONWARE = 39,
|
||||
};
|
||||
|
||||
enum ThreadContext
|
||||
{
|
||||
THREAD_CONTEXT_MAIN = 0,
|
||||
THREAD_CONTEXT_BACKEND = 1,
|
||||
THREAD_CONTEXT_WORKER0 = 2,
|
||||
THREAD_CONTEXT_WORKER1 = 3,
|
||||
THREAD_CONTEXT_WORKER2 = 4,
|
||||
THREAD_CONTEXT_WORKER3 = 5,
|
||||
THREAD_CONTEXT_WORKER4 = 6,
|
||||
THREAD_CONTEXT_WORKER5 = 7,
|
||||
THREAD_CONTEXT_WORKER6 = 8,
|
||||
THREAD_CONTEXT_WORKER7 = 9,
|
||||
THREAD_CONTEXT_SERVER = 10,
|
||||
THREAD_CONTEXT_CINEMATIC = 11,
|
||||
THREAD_CONTEXT_WINDOW = 12,
|
||||
THREAD_CONTEXT_INPUT = 13,
|
||||
THREAD_CONTEXT_DATABASE = 14,
|
||||
THREAD_CONTEXT_SOUND_STREAM = 15,
|
||||
THREAD_CONTEXT_SOUND = 16,
|
||||
THREAD_CONTEXT_UNKNOWN17 = 17,
|
||||
THREAD_CONTEXT_UNKNOWN18 = 18,
|
||||
THREAD_CONTEXT_UNKNOWN19 = 19,
|
||||
THREAD_CONTEXT_RECIPE = 20,
|
||||
};
|
||||
|
||||
namespace entity
|
||||
{
|
||||
enum connstate_t : std::uint32_t
|
||||
|
Loading…
Reference in New Issue
Block a user