| | |
| | | typedef MQId Remote; |
| | | typedef bhome_msg::MsgI MsgI; |
| | | typedef std::string Content; |
| | | typedef boost::variant2::variant<MsgI, Content> Data; |
| | | typedef int64_t Command; |
| | | typedef boost::variant2::variant<MsgI, Command> Data; |
| | | typedef std::function<void(const Data &)> OnMsgEvent; |
| | | struct MsgInfo { |
| | | Data data_; |
| | |
| | | typedef TimedMsg::TimePoint TimePoint; |
| | | typedef TimedMsg::Duration Duration; |
| | | |
| | | // template <class... Rest> |
| | | // void Append(const MQId &id, Rest &&...rest) |
| | | // { |
| | | // Append(std::string((const char *) &id, sizeof(id)), std::forward<decltype(rest)>(rest)...); |
| | | // } |
| | | |
| | | void Append(const Remote addr, const MsgI msg, OnMsgEvent onExpire = OnMsgEvent()) |
| | | { |
| | | msg.AddRef(); |
| | | AppendData(addr, Data(msg), DefaultExpire(), onExpire); |
| | | } |
| | | void Append(const Remote addr, Content &&content, OnMsgEvent onExpire = OnMsgEvent()) |
| | | void Append(const Remote addr, const Command command, OnMsgEvent onExpire = OnMsgEvent()) |
| | | { |
| | | AppendData(addr, Data(std::move(content)), DefaultExpire(), onExpire); |
| | | AppendData(addr, Data(command), DefaultExpire(), onExpire); |
| | | } |
| | | bool TrySend(ShmMsgQueue &mq); |
| | | // bool empty() const { return store_.empty(); } |
| | | |
| | | private: |
| | | static TimePoint Now() { return TimedMsg::Clock::now(); } |