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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 class MessageQueue { | 169 class MessageQueue { |
170 public: | 170 public: |
171 static const int kForever = -1; | 171 static const int kForever = -1; |
172 | 172 |
173 // Create a new MessageQueue and optionally assign it to the passed | 173 // Create a new MessageQueue and optionally assign it to the passed |
174 // SocketServer. Subclasses that override Clear should pass false for | 174 // SocketServer. Subclasses that override Clear should pass false for |
175 // init_queue and call DoInit() from their constructor to prevent races | 175 // init_queue and call DoInit() from their constructor to prevent races |
176 // with the MessageQueueManager using the object while the vtable is still | 176 // with the MessageQueueManager using the object while the vtable is still |
177 // being created. | 177 // being created. |
178 explicit MessageQueue(SocketServer* ss = NULL, | 178 MessageQueue(SocketServer* ss, bool init_queue); |
179 bool init_queue = true); | 179 MessageQueue(std::unique_ptr<SocketServer> ss, bool init_queue); |
180 | 180 |
181 // NOTE: SUBCLASSES OF MessageQueue THAT OVERRIDE Clear MUST CALL | 181 // NOTE: SUBCLASSES OF MessageQueue THAT OVERRIDE Clear MUST CALL |
182 // DoDestroy() IN THEIR DESTRUCTORS! This is required to avoid a data race | 182 // DoDestroy() IN THEIR DESTRUCTORS! This is required to avoid a data race |
183 // between the destructor modifying the vtable, and the MessageQueueManager | 183 // between the destructor modifying the vtable, and the MessageQueueManager |
184 // calling Clear on the object from a different thread. | 184 // calling Clear on the object from a different thread. |
185 virtual ~MessageQueue(); | 185 virtual ~MessageQueue(); |
186 | 186 |
187 SocketServer* socketserver(); | 187 SocketServer* socketserver(); |
188 void set_socketserver(SocketServer* ss); | 188 void set_socketserver(SocketServer* ss); |
189 | 189 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 bool fPeekKeep_; | 269 bool fPeekKeep_; |
270 Message msgPeek_; | 270 Message msgPeek_; |
271 MessageList msgq_ GUARDED_BY(crit_); | 271 MessageList msgq_ GUARDED_BY(crit_); |
272 PriorityQueue dmsgq_ GUARDED_BY(crit_); | 272 PriorityQueue dmsgq_ GUARDED_BY(crit_); |
273 uint32_t dmsgq_next_num_ GUARDED_BY(crit_); | 273 uint32_t dmsgq_next_num_ GUARDED_BY(crit_); |
274 CriticalSection crit_; | 274 CriticalSection crit_; |
275 bool fInitialized_; | 275 bool fInitialized_; |
276 bool fDestroyed_; | 276 bool fDestroyed_; |
277 | 277 |
278 private: | 278 private: |
279 // The SocketServer is not owned by MessageQueue. | 279 // The SocketServer might not be owned by MessageQueue. |
280 SocketServer* ss_ GUARDED_BY(ss_lock_); | 280 SocketServer* ss_ GUARDED_BY(ss_lock_); |
281 // If a server isn't supplied in the constructor, use this one. | 281 // Used if SocketServer ownership lies with |this|. |
282 std::unique_ptr<SocketServer> default_ss_; | 282 std::unique_ptr<SocketServer> own_ss_; |
283 SharedExclusiveLock ss_lock_; | 283 SharedExclusiveLock ss_lock_; |
284 | 284 |
285 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 285 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); |
286 }; | 286 }; |
287 | 287 |
288 } // namespace rtc | 288 } // namespace rtc |
289 | 289 |
290 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ | 290 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ |
OLD | NEW |