lichao
2021-04-15 cc6224d6e7b3f451a3ee7ecfcc7a071552498388
src/sendq.h
@@ -23,6 +23,7 @@
#include "timed_queue.h"
#include <deque>
#include <functional>
#include <list>
#include <mutex>
#include <string>
#include <unordered_map>
@@ -68,21 +69,32 @@
      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_;