--- nono/vm/scheduler.h 2026/04/29 17:05:11 1.1.1.11 +++ nono/vm/scheduler.h 2026/04/29 17:05:18 1.1.1.12 @@ -19,6 +19,8 @@ #include #include +class Syncer; + // スケジューラ class Scheduler : public ThreadDevice { @@ -26,8 +28,8 @@ class Scheduler : public ThreadDevice private: // リクエストフラグ - static const uint32 REQUEST_EXIT = 0x80000000; // 終了要求 - static const uint32 REQUEST_MESSAGE = 0x00000001; // メッセージ要求 + static const uint32 REQUEST_EXIT = 0x00000001; // 終了要求 + static const uint32 REQUEST_MESSAGE = 1U << MessageID::MAX_REQUEST; // メッセージハンドラを覚えておくための構造体 struct MessageHandler @@ -84,6 +86,7 @@ class Scheduler : public ThreadDevice // メッセージディスパッチ void DispatchMessage(); + void InvokeMessage(MessageID, uint32); DECLARE_MONITOR_CALLBACK(MonitorUpdate); @@ -97,7 +100,7 @@ class Scheduler : public ThreadDevice uint64 vtime {}; // 外部スレッドからのリクエスト - int request {}; + uint32 request {}; std::mutex mtx {}; std::condition_variable cv {}; @@ -110,10 +113,14 @@ class Scheduler : public ThreadDevice // メッセージキュー SPSCQueue msgq {}; + Syncer *syncer {}; + Monitor monitor { this }; }; extern const std::string TimeToStr(uint64 t); extern const std::string SecToStr(uint64 t); -extern Scheduler *gScheduler; +static inline Scheduler *GetScheduler() { + return Object::GetObject(OBJ_SCHEDULER); +}