| | |
| | | class SendQ |
| | | { |
| | | public: |
| | | typedef std::string Remote; |
| | | typedef MQId Remote; |
| | | typedef bhome_msg::MsgI MsgI; |
| | | typedef std::string Content; |
| | | typedef boost::variant2::variant<MsgI, Content> 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)...); |
| | | } |
| | | // 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()) |
| | | 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, Content &&content, OnMsgEvent onExpire = OnMsgEvent()) |
| | | { |
| | | AppendData(addr, Data(std::move(content)), DefaultExpire(), onExpire); |
| | | } |
| | |
| | | private: |
| | | static TimePoint Now() { return TimedMsg::Clock::now(); } |
| | | static TimePoint DefaultExpire() { return Now() + std::chrono::seconds(60); } |
| | | void AppendData(const Remote &addr, Data &&data, const TimePoint &expire, OnMsgEvent onExpire) |
| | | void AppendData(const Remote addr, Data &&data, const TimePoint &expire, OnMsgEvent onExpire) |
| | | { |
| | | //TODO simple queue, organize later ? |
| | | |
| | |
| | | typedef std::list<Array> ArrayList; |
| | | typedef std::unordered_map<Remote, ArrayList> Store; |
| | | |
| | | int DoSend1Remote(bhome_shm::ShmMsgQueue &mq, const Remote &remote, Array &arr); |
| | | int DoSend1Remote(bhome_shm::ShmMsgQueue &mq, const Remote &remote, ArrayList &arr); |
| | | int DoSend1Remote(bhome_shm::ShmMsgQueue &mq, const Remote remote, Array &arr); |
| | | int DoSend1Remote(bhome_shm::ShmMsgQueue &mq, const Remote remote, ArrayList &arr); |
| | | |
| | | std::mutex mutex_in_; |
| | | std::mutex mutex_out_; |