OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 int64_t ts_sensitive; | 145 int64_t ts_sensitive; |
146 }; | 146 }; |
147 | 147 |
148 typedef std::list<Message> MessageList; | 148 typedef std::list<Message> MessageList; |
149 | 149 |
150 // DelayedMessage goes into a priority queue, sorted by trigger time. Messages | 150 // DelayedMessage goes into a priority queue, sorted by trigger time. Messages |
151 // with the same trigger time are processed in num_ (FIFO) order. | 151 // with the same trigger time are processed in num_ (FIFO) order. |
152 | 152 |
153 class DelayedMessage { | 153 class DelayedMessage { |
154 public: | 154 public: |
155 DelayedMessage(int delay, int64_t trigger, uint32_t num, const Message& msg) | 155 DelayedMessage(int64_t delay, |
| 156 int64_t trigger, |
| 157 uint32_t num, |
| 158 const Message& msg) |
156 : cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) {} | 159 : cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) {} |
157 | 160 |
158 bool operator< (const DelayedMessage& dmsg) const { | 161 bool operator< (const DelayedMessage& dmsg) const { |
159 return (dmsg.msTrigger_ < msTrigger_) | 162 return (dmsg.msTrigger_ < msTrigger_) |
160 || ((dmsg.msTrigger_ == msTrigger_) && (dmsg.num_ < num_)); | 163 || ((dmsg.msTrigger_ == msTrigger_) && (dmsg.num_ < num_)); |
161 } | 164 } |
162 | 165 |
163 int cmsDelay_; // for debugging | 166 int64_t cmsDelay_; // for debugging |
164 int64_t msTrigger_; | 167 int64_t msTrigger_; |
165 uint32_t num_; | 168 uint32_t num_; |
166 Message msg_; | 169 Message msg_; |
167 }; | 170 }; |
168 | 171 |
169 class MessageQueue { | 172 class MessageQueue { |
170 public: | 173 public: |
171 static const int kForever = -1; | 174 static const int kForever = -1; |
172 | 175 |
173 // Create a new MessageQueue and optionally assign it to the passed | 176 // Create a new MessageQueue and optionally assign it to the passed |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // no longer be used. | 250 // no longer be used. |
248 sigslot::signal0<> SignalQueueDestroyed; | 251 sigslot::signal0<> SignalQueueDestroyed; |
249 | 252 |
250 protected: | 253 protected: |
251 class PriorityQueue : public std::priority_queue<DelayedMessage> { | 254 class PriorityQueue : public std::priority_queue<DelayedMessage> { |
252 public: | 255 public: |
253 container_type& container() { return c; } | 256 container_type& container() { return c; } |
254 void reheap() { make_heap(c.begin(), c.end(), comp); } | 257 void reheap() { make_heap(c.begin(), c.end(), comp); } |
255 }; | 258 }; |
256 | 259 |
257 void DoDelayPost(int cmsDelay, | 260 void DoDelayPost(int64_t cmsDelay, |
258 int64_t tstamp, | 261 int64_t tstamp, |
259 MessageHandler* phandler, | 262 MessageHandler* phandler, |
260 uint32_t id, | 263 uint32_t id, |
261 MessageData* pdata); | 264 MessageData* pdata); |
262 | 265 |
263 // Perform initialization, subclasses must call this from their constructor | 266 // Perform initialization, subclasses must call this from their constructor |
264 // if false was passed as init_queue to the MessageQueue constructor. | 267 // if false was passed as init_queue to the MessageQueue constructor. |
265 void DoInit(); | 268 void DoInit(); |
266 | 269 |
267 // Perform cleanup, subclasses that override Clear must call this from the | 270 // Perform cleanup, subclasses that override Clear must call this from the |
(...skipping 18 matching lines...) Expand all Loading... |
286 // Used if SocketServer ownership lies with |this|. | 289 // Used if SocketServer ownership lies with |this|. |
287 std::unique_ptr<SocketServer> own_ss_; | 290 std::unique_ptr<SocketServer> own_ss_; |
288 SharedExclusiveLock ss_lock_; | 291 SharedExclusiveLock ss_lock_; |
289 | 292 |
290 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); | 293 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); |
291 }; | 294 }; |
292 | 295 |
293 } // namespace rtc | 296 } // namespace rtc |
294 | 297 |
295 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ | 298 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ |
OLD | NEW |