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