--- nono/vm/uimessage.h 2026/04/29 17:05:46 1.1.1.4 +++ nono/vm/uimessage.h 2026/04/29 17:05:51 1.1.1.5 @@ -10,8 +10,9 @@ #pragma once -#include "fixedqueue.h" +#include "header.h" #include +#include class UIMessage { @@ -60,33 +61,23 @@ class UIMessage ID_MAX, }; - using Queue = FixedQueue; - public: UIMessage(); - UIMessage(ID id_, int arg_); + ~UIMessage(); - ID GetID() const { return id; } - int GetArg() const { return arg; } + // コールバックを指定して UIMessage サービスを開始。 + void StartUIMessage(const std::function& func_); - // メッセージ処理関数をアタッチ - static void Attach(const std::function& process_); + // UIMessage サービスを停止。 + void StopUIMessage(); - // 新しい UIMessage を生成して投函 - static void Post(ID id); - // 新しい UIMessage を生成して投函(argあり) - static void Post(ID id, int arg); - - protected: - // 自身を投函 - void Post(); + // UIMessage をポスト (コールバックを実行)。 + void Post(uint id) { + Post(id, 0); + } + void Post(uint id, int arg); private: - ID id {}; - int arg {}; - - static Queue queue; - - // メッセージ処理コールバック - static std::function process; + std::function func {}; + std::mutex mtx {}; };