--- nono/vm/scheduler.h 2026/04/29 17:04:53 1.1.1.8 +++ nono/vm/scheduler.h 2026/04/29 17:04:59 1.1.1.10 @@ -10,6 +10,7 @@ #include "event.h" #include "eventqueue.h" #include "fixedqueue.h" +#include "monitor.h" #include "mpu.h" #include "statistics.h" #include "stopwatch.h" @@ -79,15 +80,18 @@ class Scheduler : public Device bool Init() override; - nnSize GetMonitorSize() override; - void MonitorUpdate(TextScreen&) override; - // スレッド開始 void ThreadRun(); // スレッド終了 void Terminate(); + // スレッド終了を待機する + void Wait(); + + // スレッド終了を指示する + void RequestExit(); + // 電源オン要求 // 当然電源オフ時に呼ぶので VM スレッド外から呼ばれることになる。 void RequestPowerOn() { @@ -138,9 +142,6 @@ class Scheduler : public Device // イベントを停止する void StopEvent(Event *event); - // VM 電源オフ時のコールバックを設定する。(GUI から呼ばれる) - void SetPowerOffCallback(void (*callback)()); - // パフォーマンスカウンタの値取得 (UI 表示用) int GetPerfCounter() const { return perf_counter; } @@ -151,6 +152,8 @@ class Scheduler : public Device // 同期イベント void SyncCallback(Event& ev); + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + // メインループ bool RunOff(); bool RunOn(); @@ -164,9 +167,6 @@ class Scheduler : public Device // REQ_* フラグのデバッグ表示 void PutlogReqFlag(uint32 req) const; - // スレッド終了を指示する - void RequestExit(); - pthread_t thread {}; bool thread_created {}; // スレッドが作成されたら true @@ -221,12 +221,13 @@ class Scheduler : public Device Statistics last_event_stat {}; // 直近実1秒のイベント統計 // 同期イベント - Event sync_event {}; + Event sync_event { this }; - // 電源オフを UI に通知するためのコールバック - void (*poweroff_callback)() {}; + Monitor monitor { this }; }; +extern const std::string TimeToStr(uint64 t); + extern Stopwatch gRealtime; extern std::unique_ptr gScheduler;