| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 int cmsDelay_; // for debugging | 160 int cmsDelay_; // for debugging |
| 161 uint32_t msTrigger_; | 161 uint32_t msTrigger_; |
| 162 uint32_t num_; | 162 uint32_t num_; |
| 163 Message msg_; | 163 Message msg_; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 class MessageQueue { | 166 class MessageQueue { |
| 167 public: | 167 public: |
| 168 static const int kForever = -1; | 168 static const int kForever = -1; |
| 169 | 169 |
| 170 explicit MessageQueue(SocketServer* ss = NULL); | 170 explicit MessageQueue(SocketServer* ss = NULL, |
| 171 bool add_to_queue_manager = true); |
| 172 // NOTE: ALL SUBCLASSES OF MessageQueue MUST CALL DoDestroy() IN THEIR |
| 173 // DESTRUCTORS! This is required to avoid a data race between the destructor |
| 174 // modifying the vtable, and the MessageQueue being removed from the |
| 175 // MessageQueueManager. |
| 171 virtual ~MessageQueue(); | 176 virtual ~MessageQueue(); |
| 172 | 177 |
| 173 SocketServer* socketserver() { return ss_; } | 178 SocketServer* socketserver() { return ss_; } |
| 174 void set_socketserver(SocketServer* ss); | 179 void set_socketserver(SocketServer* ss); |
| 175 | 180 |
| 176 // Note: The behavior of MessageQueue has changed. When a MQ is stopped, | 181 // Note: The behavior of MessageQueue has changed. When a MQ is stopped, |
| 177 // futher Posts and Sends will fail. However, any pending Sends and *ready* | 182 // futher Posts and Sends will fail. However, any pending Sends and *ready* |
| 178 // Posts (as opposed to unexpired delayed Posts) will be delivered before | 183 // Posts (as opposed to unexpired delayed Posts) will be delivered before |
| 179 // Get (or Peek) returns false. By guaranteeing delivery of those messages, | 184 // Get (or Peek) returns false. By guaranteeing delivery of those messages, |
| 180 // we eliminate the race condition when an MessageHandler and MessageQueue | 185 // we eliminate the race condition when an MessageHandler and MessageQueue |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 container_type& container() { return c; } | 239 container_type& container() { return c; } |
| 235 void reheap() { make_heap(c.begin(), c.end(), comp); } | 240 void reheap() { make_heap(c.begin(), c.end(), comp); } |
| 236 }; | 241 }; |
| 237 | 242 |
| 238 void DoDelayPost(int cmsDelay, | 243 void DoDelayPost(int cmsDelay, |
| 239 uint32_t tstamp, | 244 uint32_t tstamp, |
| 240 MessageHandler* phandler, | 245 MessageHandler* phandler, |
| 241 uint32_t id, | 246 uint32_t id, |
| 242 MessageData* pdata); | 247 MessageData* pdata); |
| 243 | 248 |
| 249 // Perform cleanup, subclasses must call this from the destructor. |
| 250 void DoDestroy(); |
| 251 |
| 244 // The SocketServer is not owned by MessageQueue. | 252 // The SocketServer is not owned by MessageQueue. |
| 245 SocketServer* ss_; | 253 SocketServer* ss_; |
| 246 // If a server isn't supplied in the constructor, use this one. | 254 // If a server isn't supplied in the constructor, use this one. |
| 247 scoped_ptr<SocketServer> default_ss_; | 255 scoped_ptr<SocketServer> default_ss_; |
| 248 bool fStop_; | 256 bool fStop_; |
| 249 bool fPeekKeep_; | 257 bool fPeekKeep_; |
| 250 Message msgPeek_; | 258 Message msgPeek_; |
| 251 MessageList msgq_; | 259 MessageList msgq_; |
| 252 PriorityQueue dmsgq_; | 260 PriorityQueue dmsgq_; |
| 253 uint32_t dmsgq_next_num_; | 261 uint32_t dmsgq_next_num_; |
| 254 CriticalSection crit_; | 262 CriticalSection crit_; |
| 263 bool fDestroyed_; |
| 255 | 264 |
| 256 private: | 265 private: |
| 257 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 266 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
| 258 }; | 267 }; |
| 259 | 268 |
| 260 } // namespace rtc | 269 } // namespace rtc |
| 261 | 270 |
| 262 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ | 271 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ |
| OLD | NEW |