--- nono/vm/thread.h 2026/04/29 17:05:28 1.1.1.4 +++ nono/vm/thread.h 2026/04/29 17:05:50 1.1.1.5 @@ -14,22 +14,26 @@ #include #include -class ThreadDevice : public Device +class ThreadBase { - using inherited = Device; - public: + protected: enum class AffinityClass { Light, // 処理の軽いスレッド Heavy, // 処理の重いスレッド }; + // このスレッドのアフィニティを示唆する + static void SetThreadAffinityHint(AffinityClass hint); +}; + +class ThreadDevice : public Device, public ThreadBase +{ + using inherited = Device; + public: explicit ThreadDevice(uint objid_); ~ThreadDevice() override; - // スレッド名を設定する - void SetThreadName(const char *threadname_); - // スレッドを開始する virtual bool StartThread(); @@ -37,20 +41,23 @@ class ThreadDevice : public Device void TerminateThread(); protected: + // オブジェクト名とスレッド名を設定する。 + void SetName(const std::string& newname) override; + + // スレッド名を設定する + void SetThreadName(const std::string& threadname_); + // スレッドエントリポイント virtual void ThreadRun() = 0; // スレッドに終了を指示する virtual void Terminate() = 0; - // このスレッドのアフィニティを示唆する - void SetThreadAffinityHint(AffinityClass hint); - std::unique_ptr thread {}; // スレッド開始同期用 std::mutex thread_starter {}; // スレッド名 - const char *threadname {}; + std::string threadname {}; };