webrtc MessageQueue 处理过程

webrtc MessageQueue 处理过程_第1张图片
Message.png

MessageQueue中包含两种数据队列
MessageList msgq_ ;

typedef std::list MessageList;

PriorityQueue dmsgq_;//优先队列

 class PriorityQueue : public std::priority_queue {
   public:
    container_type& container() { return c; }
    void reheap() { make_heap(c.begin(), c.end(), comp); }
  };

优先队列继承自 std::priority_queue
DelayerMessage实现

class DelayedMessage {
 public:
  DelayedMessage(int64_t delay,
                 int64_t trigger,
                 uint32_t num,
                 const Message& msg)
      : cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) {}

  bool operator< (const DelayedMessage& dmsg) const {
    return (dmsg.msTrigger_ < msTrigger_)
           || ((dmsg.msTrigger_ == msTrigger_) && (dmsg.num_ < num_));
  }

  int64_t cmsDelay_;  // for debugging
  int64_t msTrigger_;
  uint32_t num_;
  Message msg_;
};

重载 小于操作符operator< (),sorted by trigger time,小值在前。

你可能感兴趣的:(webrtc MessageQueue 处理过程)