CompThr: Expose name arg for CompThr derivatives' ctors

This enables us to statically set the thread names at compile time,
or at least during construction at runtime.

This completes the crux of the splitting work required to
functionally split libspinscale off from SMO.
This commit is contained in:
2026-02-22 18:51:21 -04:00
parent a7521f3760
commit b4b61bb2b6

View File

@@ -33,16 +33,13 @@ typedef uint8_t ThreadId;
class ComponentThread class ComponentThread
{ {
protected: protected:
ComponentThread(ThreadId _id) ComponentThread(ThreadId _id, std::string _name)
: id(_id), name(getThreadName(_id)), work(io_service) : id(_id), name(std::move(_name)), work(io_service)
{} {}
public: public:
virtual ~ComponentThread() = default; virtual ~ComponentThread() = default;
// getThreadName implementation is provided by application code
static std::string getThreadName(ThreadId id);
void cleanup(void); void cleanup(void);
boost::asio::io_service& getIoService(void) { return io_service; } boost::asio::io_service& getIoService(void) { return io_service; }
@@ -96,10 +93,11 @@ public:
using entryPointFn = std::function<void(const EntryFnArguments &)>; using entryPointFn = std::function<void(const EntryFnArguments &)>;
PuppeteerThread( PuppeteerThread(
ThreadId id, entryPointFn entryPoint, ThreadId id, std::string name,
entryPointFn entryPoint,
pptr::PuppeteerComponent &component, pptr::PuppeteerComponent &component,
preJoltHookFn preJoltFn) preJoltHookFn preJoltFn)
: ComponentThread(id), : ComponentThread(id, std::move(name)),
entryFnArguments(*this, component, preJoltFn), entryFnArguments(*this, component, preJoltFn),
thread(std::move(entryPoint), std::cref(entryFnArguments)) thread(std::move(entryPoint), std::cref(entryFnArguments))
{} {}
@@ -148,9 +146,10 @@ public:
}; };
PuppetThread( PuppetThread(
ThreadId _id, entryPointFn entryPoint, PuppetComponent &component, ThreadId _id, std::string name,
entryPointFn entryPoint, PuppetComponent &component,
preJoltHookFn preJoltFn) preJoltHookFn preJoltFn)
: ComponentThread(_id), : ComponentThread(_id, std::move(name)),
pinnedCpuId(-1), pinnedCpuId(-1),
pause_work(pause_io_service), pause_work(pause_io_service),
entryFnArguments(*this, component, preJoltFn), entryFnArguments(*this, component, preJoltFn),