| | |
| | | #include "timed_queue.h" |
| | | #include <deque> |
| | | #include <functional> |
| | | #include <list> |
| | | #include <mutex> |
| | | #include <string> |
| | | #include <unordered_map> |
| | |
| | | msg.AddRef(); |
| | | TimedMsg tmp(expire, MsgInfo{msg, onExpire}); |
| | | std::unique_lock<std::mutex> lock(mutex_); |
| | | in_[addr].emplace_back(std::move(tmp)); |
| | | auto &al = in_[addr]; |
| | | if (!al.empty()) { |
| | | al.front().emplace_back(std::move(tmp)); |
| | | } else { |
| | | al.insert(al.begin(), Array())->emplace_back(std::move(tmp)); |
| | | } |
| | | } |
| | | typedef std::deque<TimedMsg> MsgList; |
| | | typedef std::unordered_map<Remote, MsgList> Store; |
| | | typedef std::deque<TimedMsg> Array; |
| | | 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); |
| | | |
| | | class MsgIter |
| | | { |
| | | MsgList::iterator iter_; |
| | | Array::iterator iter_; |
| | | |
| | | public: |
| | | MsgIter(MsgList::iterator iter) : |
| | | MsgIter(Array::iterator iter) : |
| | | iter_(iter) {} |
| | | MsgIter &operator++() { return ++iter_, *this; } |
| | | bool operator==(const MsgIter &a) { return iter_ == a.iter_; } |
| | | MsgI &operator*() { return iter_->data().msg_; } |
| | | }; |
| | | |
| | | std::mutex mutex_; |
| | | Store in_; |
| | | Store out_; |