Thread: Add name parameter

For debugging purposes, threads can be assigned a name, which eases
distinguishing between them in e.g. htop or gdb. This uses a
Linux-specific API for now which is limited to 15 characters (+ null
terminator), so truncation is done and names for existing thread
instantiations were chosen to be consise.

[Kieran: Apply checkstyle suggestions, rebase on proxy rework]
Signed-off-by: Schulz, Andreas <andreas.schulz2@karlstorz.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Schulz, Andreas
2025-11-04 18:50:02 +00:00
committed by Kieran Bingham
parent 6af90deaf2
commit 559128b1f1
6 changed files with 17 additions and 7 deletions
+3 -1
View File
@@ -8,6 +8,7 @@
#pragma once
#include <memory>
#include <string>
#include <sys/types.h>
#include <thread>
@@ -30,7 +31,7 @@ class ThreadMain;
class Thread
{
public:
Thread();
Thread(std::string name = {});
virtual ~Thread();
void start();
@@ -74,6 +75,7 @@ private:
void moveObject(Object *object, ThreadData *currentData,
ThreadData *targetData);
std::string name_;
std::thread thread_;
std::unique_ptr<ThreadData> data_;
};