--- nono/lib/mainapp.h 2026/04/29 17:05:48 1.1.1.18 +++ nono/lib/mainapp.h 2026/04/29 17:05:57 1.1.1.20 @@ -10,11 +10,14 @@ #pragma once -#include "object.h" +#include "header.h" +#include class Config; class Logger; class MonitorManager; +class Object; +class ThreadManager; class UIMessage; class VM; @@ -42,7 +45,7 @@ enum class VMCap : uint32 { M88K = VMCap::LUNA88K, ALL = 0xffffffff, }; -static inline VMCap operator|(VMCap a, VMCap b) { +inline VMCap operator|(VMCap a, VMCap b) { return static_cast(static_cast(a) | static_cast(b)); } @@ -52,11 +55,15 @@ class MainApp // Init() の戻り値 static const int PASS = -1; // 実行を継続 - enum class CPUAffinity { - None, // 指定なし - Low, // 低電力コアを列挙 - High, // 高性能コアを列挙 - Perf, // 高性能コアを列挙 (パフォーマンス測定用) + // CPU のバインド方法。 + // o Neutral は何もしない。 + // o Binding は、Heavy スレッドを高性能コアにバインドする。 + // Light スレッドは + // 高性能コアが 3個以上あれば、バインドしない (OS に任せる)。 + // 高性能コアが 2個以下なら、低性能コアにバインドする + enum class AffinityPolicy { + Neutral, + Binding, }; public: @@ -140,9 +147,15 @@ class MainApp // ログ名の一覧を表示する static std::vector GetLogNames(); + // list を一覧表示をする + static void ShowHelpList(FILE*, const std::vector& list); + // Logger を返す Logger *GetLogger() const { return logger.get(); } + // ThreadManager を返す + ThreadManager *GetThreadManager() const { return threadmanager.get(); } + // UIMessage を返す UIMessage *GetUIMessage() const { return uimessage.get(); } @@ -194,11 +207,11 @@ class MainApp // NEON をホストがサポートしているかどうか。(こっちは情報表示用) bool detect_neon {}; - // CPU コアのアフィニティ。 - CPUAffinity cpu_affinity {}; + // CPU のバインド方法。 + AffinityPolicy affinity_policy {}; - // 要素数がコア数。true のところが cpu_affinity で指定した性質のコアを示す。 - std::vector cpu_list {}; + // 要素数がコア数。高性能コアのところが true。 + std::vector fastcore {}; // ログ表示用 std::unique_ptr hostcpu /*{}*/; @@ -229,14 +242,19 @@ class MainApp // CPU の機能をチェックする。 bool CheckCPU(); + // CPU のアフィニティを調べる。 + bool CheckCPUAffinity(); + // CPU 番号リスト文字列を処理する。 - std::string ParseCPUList(std::vector& dst, const std::string& input); + std::string ParseCPUList(const std::string& input); // opt を logopt に追加する (-L オプション用) void AddLogopt(const char *opt); // -L オプションを処理する bool ParseLogopt(); + // 早期版 + void ParseLogoptEarly(); // ログレベル1つを設定する。 static bool SetLogopt1(const std::string&, std::string *errmsg); @@ -266,6 +284,9 @@ class MainApp VMType vmtype {}; std::string vmstr {}; + // スレッドマネージャ + std::unique_ptr threadmanager /*{}*/; + // モニタマネージャ std::unique_ptr pMonitorManager /*{}*/; @@ -279,6 +300,9 @@ class MainApp // -L: ログ指定文字列 std::string logopt {}; + // --perf: パフォーマンス測定モード + bool opt_perf {}; + // --show-config: 設定内容を表示 (1なら通常、2ならall) int show_config {};