--- nono/vm/scheduler.h 2026/04/29 17:05:25 1.1.1.13 +++ nono/vm/scheduler.h 2026/04/29 17:05:51 1.1.1.16 @@ -11,14 +11,13 @@ #pragma once #include "thread.h" -#include "event.h" #include "message.h" -#include "monitor.h" #include "spscqueue.h" #include #include #include +class EventManager; class Syncer; // スケジューラ @@ -43,6 +42,7 @@ class Scheduler : public ThreadDevice ~Scheduler() override; bool Init() override; + bool Init2(); void StartTime(); @@ -52,20 +52,17 @@ class Scheduler : public ThreadDevice // 現在のマスター仮想時間を返す uint64 GetVirtTime() const { return vtime; } - // イベントを登録する - void RegistEvent(Event& ev); - // イベントを開始する - void StartEvent(Event& ev); - void RestartEvent(Event& ev); + void StartEvent(Event *ev); + void RestartEvent(Event *ev); // 実時間間隔を指定してイベントを開始する。 // rt_now はイベント発行者の実時間での現在時刻で、 // rt_period は次回のイベントまでの実時間間隔。 - void StartRealtimeEvent(Event& ev, uint64 rt_now, uint64 rt_period); + void StartRealtimeEvent(Event *ev, uint64 rt_now, uint64 rt_period); // イベントを停止する - void StopEvent(Event& ev); + void StopEvent(Event *ev); // メッセージハンドラを登録する void ConnectMessage(MessageID, Device *, MessageCallback_t); @@ -80,9 +77,9 @@ class Scheduler : public ThreadDevice // スレッド void ThreadRun() override; - void EnqueueSlow(Event& ev); - void PushSlow(Event& ev); - void StopSlowEvent(Event& ev); + void EnqueueSlow(Event *); + void PushSlow(Event *); + void StopSlowEvent(Event *); // メッセージディスパッチ void DispatchMessage(); @@ -104,23 +101,18 @@ class Scheduler : public ThreadDevice std::mutex mtx {}; std::condition_variable cv {}; - // 全イベントのリスト (所有はしていない) - std::vector all_events {}; - // メッセージハンドラリスト std::array message_handlers {}; // メッセージキュー SPSCQueue msgq {}; + EventManager *evman {}; Syncer *syncer {}; - Monitor monitor { this }; + Monitor *monitor {}; }; -extern const std::string TimeToStr(uint64 t); -extern const std::string SecToStr(uint64 t); - static inline Scheduler *GetScheduler() { return Object::GetObject(OBJ_SCHEDULER); }